Skip to content

feat: TS streaming — stream let emits rt.llmStream - #29

Merged
NekomyaDev merged 2 commits into
mainfrom
feature/ts-streaming
Jul 29, 2026
Merged

NekomyaDev merged 2 commits into
mainfrom
feature/ts-streaming

Conversation

@NekomyaDev

Copy link
Copy Markdown
Owner

What

TS parity step: stream let no longer degrades to a plain call with a warning — the TS runtime gains llmStream and codegen emits it.

  • Fake-provider parity with Python's llm_stream: deterministic 14-char chunking, additive streamed/chunks trace fields, replay consumes the recorded value (§6.2), branch labels compose with par lanes
  • Streamed prefix validation and the repair loop stay Python-side (noted in the header)
  • The real-provider guard in llmStream recognizes all seven provider prefixes

Test

Node e2e: schema stream chunks == ceil(JSON length / 14) exactly as Python computes; string stream same; trace records carry streamed: true ✓

@NekomyaDev
NekomyaDev merged commit 3e39676 into main Jul 29, 2026
2 checks passed
@NekomyaDev
NekomyaDev deleted the feature/ts-streaming branch July 29, 2026 18:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18ca983ccb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread runtime/nudge_runtime.ts
Comment on lines +229 to +231
const prefix = model && model.includes(":") ? model.split(":")[0] : null;
if ((process.env.NUDGE_PROVIDER && process.env.NUDGE_PROVIDER !== "fake") ||
(prefix && ["openai", "gemini", "groq", "mimo", "mistral", "anthropic", "ollama"].includes(prefix))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor the explicit fake-provider override

When NUDGE_PROVIDER=fake is set and the model has a recognized prefix such as anthropic:..., the first condition is false but the prefix condition still throws, so deterministic fake streaming cannot run with the same realistic model names used by generated programs. The explicit fake setting should suppress prefix-based real-provider detection, as it does in the Python runtime.

Useful? React with 👍 / 👎.

format!("const {name} = {}; // warning: streaming not yet supported by the TS backend — plain call", ts(value, aliases, sigs))
// the TS runtime now streams (fake parity): swap the
// emitted llmCall for llmStream — same opts shape
let call = ts(value, aliases, sigs).replacen("rt.llmCall(", "rt.llmStream(", 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Only rewrite a direct streamed LLM call

When a non-LLM stream let expression contains a nested LLM call, such as stream let x = (llm"""...""" with {...}) + "suffix", this string replacement converts that nested call to llmStream. The language permits non-LLM streamed bindings and defines them to degrade to a plain binding, so codegen should pattern-match Expr::LlmCall as the Python backend does rather than replacing the first emitted call anywhere in the expression.

Useful? React with 👍 / 👎.

Comment thread runtime/nudge_runtime.ts
Comment on lines +238 to +239
const text = sch ? JSON.stringify(out) : String(out);
const chunks = text.length === 0 ? 1 : Math.ceil(text.length / chunkSize);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match Python JSON serialization when counting chunks

For schema-backed streams, JSON.stringify uses compact separators while Python's json.dumps inserts spaces, so the recorded chunk count is not actually deterministic across backends. For example, {a: true, b: true, c: true} serializes to 28 UTF-16 units here (2 chunks) but 33 characters in Python (3 chunks), causing otherwise equivalent fake runs to produce different chunks trace data.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant