-
Notifications
You must be signed in to change notification settings - Fork 139
Epic: ModelOutputThunk structural cleanup #909
Copy link
Copy link
Labels
area/componentComponent type system, CBlock, @generative decorator, prompt templates, RichDocumentComponent type system, CBlock, @generative decorator, prompt templates, RichDocumentarea/samplingSamplingStrategy, SamplingResult, ModelOption, generation optionsSamplingStrategy, SamplingResult, ModelOption, generation optionsarea/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationarea/streamingStreaming chunks, events, per-chunk validationStreaming chunks, events, per-chunk validationenhancementNew feature or requestNew feature or requestepicHigh level EpicHigh level Epicp2Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.refactor
Description
Metadata
Metadata
Assignees
Labels
area/componentComponent type system, CBlock, @generative decorator, prompt templates, RichDocumentComponent type system, CBlock, @generative decorator, prompt templates, RichDocumentarea/samplingSamplingStrategy, SamplingResult, ModelOption, generation optionsSamplingStrategy, SamplingResult, ModelOption, generation optionsarea/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationarea/streamingStreaming chunks, events, per-chunk validationStreaming chunks, events, per-chunk validationenhancementNew feature or requestNew feature or requestepicHigh level EpicHigh level Epicp2Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.Medium/low: minor bugs, niche features, polish, docs, tests, cleanup. Scoped, lower urgency.refactor
Goal
Reshape
ModelOutputThunk's internal layout to make the public surface explicit, the private surface coherent, and copy semantics structural rather than per-field.Areas
mot.rawnamespacetelemetry_span/ OTel ownership_call/_gensub-objects_thinking→ publicmot.thinkingTL;DR
_meta[...]keys (chat_response,oai_chat_response, etc.) onto a typedmot.raw: RawProviderResponsenamespace. Migratechat.py:_parseto switch onmot.raw.provider.mot._call(originating call, preserved across copies) andmot._gen(in-flight machinery, reset on copy). Add a guard that raises on copy-of-uncomputed-MOT._thinking) — promote to publicmot.thinkingwith a property alias for_thinkingthrough one deprecation cycle.mot.generate_logas a public property, and add a publicmot.errorchannel so callers can detect a soft-failed thunk without reading private state.Sequencing
_generation_idto Area 3's field set.Coordinated, not in scope
_genshape will accommodate parsed-repr stream buffers; do not block on feat: Phase 2 — validated streaming #1013, which could remain a placeholder for months.mot.generation(e.g.generation.logprobs), notmot.raw. Per ModelOutputThunk field refactor: partition fields into sub-structures #793 precedent.ModelOutputThunkshould not be aCBlock#269 (MOT-not-CBlock) — orthogonal. If acted on later, Area 1'smot.rawis unaffected.Related bugs (discovered during audit, filed separately)
fix(backends): unify raw-path token usage on mot.generation.usage; guard eval_count=Nonefix(streaming): use public mot.cancelled property in streaming.py:437Messagehas nothinkingfield; reasoning silently dropped in multi-turn chat (coordinated with Area 4)Cross-cutting constraints
_metaisCBlocksurface, not just MOT surface. This epic does not changeCBlock._meta; it only removes MOT's writes into the dict.mot._thinking,mot._meta[<keys>], andmot._generate_logare read by code outsidebase.pytoday; renames need property aliases for one minor release.cancel_generation(),mot._async_queuesingle-consumer semantics, andmot.cancelledare load-bearing forstream_with_chunking()(feat(stdlib): add stream_with_chunking() with per-chunk validation (#901) #942).DeprecationWarningaliases for one minor cycle, then remove.