Skip to content

Responses: one level of namespace tools, flattened for the engine, name+namespace restored on call items - #3610

Merged
ashhart merged 7 commits into
ashhart:mainfrom
devopsfortunato:responses-namespace-tools
Nov 20, 2026
Merged

ashhart merged 7 commits into
ashhart:mainfrom
devopsfortunato:responses-namespace-tools

Conversation

@devopsfortunato

@devopsfortunato devopsfortunato commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Responses accepts one level of namespace function tools. The engine sees <namespace>__<tool>; function-call items restore the child's name and namespace. Flat-only requests retain main's behavior. Children whose own names already start with their group's prefix are refused before an ambiguous history round trip, and empty input namespaces consistently refuse.

Checks on this head

  • Head commit: 8b16b9089177bf9573f19787cc86915deb6cdbc7.
  • Lean checker, python3 tools/zig/lean_check.py, on fresh archived base f5765b51254d7ec7ef1295e23cb500f328165600 and this head: 221 / 221 inherited problems, 0 new, verified with lean_new.py. responses.zig is exactly 600 lines, with a net-zero line delta against the rebased base; responses_translate.zig is 591 lines.
  • Current-head CPU cross-check: umask 022; zig build test-server-cpu test-golden test-server-security test-pull-security -j2 --test-timeout 10m --summary all, Zig 0.17.0, task-local cache, no GPU execution: 23/23 steps succeeded; 1,671 passed, 8 skipped, 0 failed (1,679 total). The server CPU test artifacts account for 1,621 passes and 8 skips. HTTP goldens use a real local listener: 324/337 and 55/55 equal, 0 unexpected differences; the other 13 corpus differences are the existing recorded qualifications. Both whole and streamed namespace cases are included.
  • Formatting and whitespace: zig fmt --check build.zig zig and git diff --check pass on this head.
  • CI: 9 successful checks, 2 scheduled/nightly checks skipped, 0 failures or pending checks on this exact head. No GPU run and Zig format. The actual zig job steps confirm successful test-host-a, test-golden, kernel contract, serving contracts, security and fuzz gates; zig-b confirms successful test-host-b. Windows, macOS developer tools, pytest, release paths and both benchmark-client checks also passed.
  • Not run locally: the full host aggregate and other platform jobs were verified in the exact-head CI above, not rerun on the CPU cross-check machine. Device/checkpoint and throughput runs were not performed; the maintainer explicitly confirmed they are unnecessary for this translation-only change.

Review requests addressed

  1. Flat-only function behavior remains unchanged, including duplicate names, defer_loading and name-less allowed_tools entries. Namespace/flat twins retain chat-body and rendered-prompt equivalence coverage.
  2. An input namespace that is not offered is refused by name. A namespace child whose own name starts with <group>__ is refused before output can round-trip to another tool; an ordinary flat function with that spelling remains valid. Empty namespaces refuse in both raw translation and the message converter.
  3. Output name/namespace fields are written through the translation helper, preserving field order and allocation-error handling while keeping the response module at 600 lines. The unused allocator and the requested comment/document wrapping issues are fixed.
  4. Whole/SSE, stored-history, WebSocket and isolated namespace goldens remain covered. The maintainer preserved main's generated corpus during the rebase.

The maintainer's follow-up records 60 namespace tests passing and exactly the two new regressions failing when the old behaviors are restored. The current-head real-listener run above closes the HTTP-golden validation gap described there.

Receipt

  • Main against branch: namespace/flat-equivalent chat bodies and rendered prompt IDs are pinned by the current CPU suite; the HTTP corpus has zero unexpected differences. No model benchmark was requested for this translation-only change.
  • Boxes it reaches: Responses tool/input translation, tool choice, whole/SSE output, stored continuation and WebSocket turns.
  • New switch? n/a — no new setting or profile row.
  • Environment: base f5765b51254d7ec7ef1295e23cb500f328165600, head 8b16b9089177bf9573f19787cc86915deb6cdbc7; Zig 0.17.0; Linux aarch64 CPU-only validation, -j2, isolated cache. No checkpoint, model revision or GPU/backend toolchain was involved.
  • Paths/platforms: real HTTP/golden/security and server CPU tests run on aarch64 Linux; full Linux host shards, Windows and macOS developer-tool coverage verified through the exact-head CI linked above.
  • Exactness: request/chat-body and prompt-ID equality plus HTTP golden comparisons, not a checkpoint token-hash claim. Kernel, sampling and lane-round code is unchanged.
  • Main against this branch, same checkpoint: n/a — no checkpoint execution; the maintainer waived device runs for this request/response translation change.
  • Decode speed before/after: n/a — no kernel, decode or arithmetic change; no speed claim.
  • Cold prompt speed before/after: not measured; translation equivalence is tested, and device/model performance runs were waived. No throughput claim.
  • Licence of new weights/drafter: n/a — no weights or drafter added.

Checklist

  • Title and description match the actual head, receipt and rebased stack.
  • The maintainer recorded two behavioral regression failures with old behavior restored; the current complete CPU suite and exact-head CI pass. Missing optional dependencies are reported as skips.
  • Comments/docstrings follow the single-line/120-column rule with zero new lean findings; no measurements or history were added to source comments.
  • No private paths, hosts or credentials were added to the diff or commits. All four PR commits have GitHub noreply author and committer identities; no attribution trailers were added.
  • Lane rounds, draft policy, sampling and precision are unchanged. Device/drafted/concurrent token checks and decode/prompt throughput cells are n/a under the maintainer's explicit translation-only test scope, not claims that such model runs were performed.

ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 17, 2026
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. This follows the shape we set out on #3266, and the work shows in the details. A flat name maps back to its child's name and namespace from the request's own tools (responses.zig, Reply.open), so whole replies, SSE, stored responses and WebSocket all agree. History flattens without prefixing twice. And tool_choice refuses an unqualified name that two namespaces share. On current main the server CPU suite, the goldens (0 unexpected differences) and the security checks all pass, and the lean check is unchanged at 221.

To land, these need changing:

  1. Requests with only function tools must behave exactly as on main. That was point 4 of our list on Responses API: accept namespace tools (Codex CLI sends its MCP and multi-agent tools as namespaces) #3266. Three changes here alter them:

    • two plain functions with the same name are now refused (uniqueName);
    • defer_loading on a plain function is now refused;
    • an allowed_tools function entry without a string name is now refused, where main drops it.

    Please keep these checks for requests that offer a namespace, where a clash really is ambiguous, and leave flat-only requests as they are.

  2. History from a namespace that isn't offered. A function_call input item whose namespace isn't among the offered tools should be refused by name (point 3 on Responses API: accept namespace tools (Codex CLI sends its MCP and multi-agent tools as namespaces) #3266). Today flatName renders it flat whatever the tools are.

  3. Tests. Please add the ones we asked for that aren't here yet:

    • a host test that a namespaced request's chat body, and so its prompt, equals the equivalent flat-function request's;
    • a WebSocket turn offering a namespace;
    • golden cases for a namespaced request, streamed and not.

    The goldens are recorded with zig/tests/server/freeze_cases.py. Put them on a server step of their own so the main corpus's request log stays unchanged.

We added one commit on top with the CHANGELOG line under ## Unreleased.

No device run is needed: this is request and response translation only, so tokens can't change.

  • Synthena

@devopsfortunato

Copy link
Copy Markdown
Contributor Author

All three review asks are addressed on the new head 89ab9d2ea:

  1. Flat-only requests behave exactly as main — the duplicate-name and defer_loading checks engage only when a namespace is offered, and name-less allowed_tools entries drop silently on flat-only requests, as on main. Tests pin both shapes side by side (responses_namespace_translate_test.zig).
  2. History from an unoffered namespace is refused by name — inputNamespaces validates the raw client function_call items against the offered groups at the shared translation entry and refuses with the offending name (namespace 'ops' is not among offered...). The trusted output→history conversion keeps its old shape, so stored continuations are unaffected.
  3. Tests — namespaced vs flat twins assert byte-equal chat bodies and equal rendered prompt ids; a real WebSocket namespace turn is compared with its SSE twin and continued through previous_response_id; whole and streamed namespace goldens run on a fourth, isolated serve step so the original corpus (including lifecycle/request-log.json) is byte-identical.

The WebSocket fixture sets reasoning: {"effort":"none"} so the visible-text assertion is not consumed by the thinking lane. Local gates on this head: test-server-cpu 1528/1536 (8 skipped, 0 failed); test-golden 5/5 steps, 0 unexpected differences; the host leaf steps (glm snapshots, qwen3-cuda, flashnext nonfinite/draw, glm lane costs, cuda-host 410/410 with 4519/4543 passed/24 skipped, glm logprobs) and the remaining CI steps (kernel-contract, gradient-serving, qwen-serving-host, server-security, pull-security, fuzz-cortheon) all exit 0; lean 221/221 with 0 new; zig fmt --check and git diff --check clean. Device runs per your note: not needed.

devopsfortunato pushed a commit to devopsfortunato/TensorFold that referenced this pull request Nov 18, 2026
@devopsfortunato
devopsfortunato force-pushed the responses-namespace-tools branch from 89ab9d2 to 9e379ff Compare November 18, 2026 02:56
@devopsfortunato

Copy link
Copy Markdown
Contributor Author

Follow-up: the branch is now rebased on main (af9777b49), with the maintainer’s changelog entry preserved. Current head is 9e379ff48 and the PR is mergeable. All nine CI checks passed; the two nightly jobs were skipped. The three requested changes and regression coverage are described in the previous reply. Ready for another review—thanks!

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. All three asks from our last review are resolved on this head:

  1. Requests with only function tools behave as on main. Duplicate names and defer_loading are checked only when a namespace is offered (responses_translate.zig:318), and an allowed_tools entry without a name is dropped (:405). The tests at responses_namespace_translate_test.zig:220-233 and :358-386 pin both shapes, and :80-86 pins the flat tools' bytes.
  2. A function_call item whose namespace isn't offered is refused by name (inputNamespaces, responses_translate.zig:257-264, called at :491).
  3. The tests are in. A namespaced request's chat body and prompt ids equal its flat twin's (responses_namespace_translate_test.zig:235-268). A WebSocket turn offers a namespace and continues from it (responses_ws_test.zig:281). The two goldens sit on a step of their own, and the first three steps of cases.json are unchanged.

I also checked that a request without namespace tools gets the same chat body and the same reply items as on main, so its prompt and tokens can't change.

What remains:

  1. zig/src/server/responses.zig is 604 lines on current main, over our 600-line limit. Since your branch point, main has grown the file to exactly 600 lines, and your 4 lines in Reply.open (:303-307) push it over. One way out: a helper in responses_translate.zig that writes name, plus namespace when there is one, onto the item, so open calls it in one line.
  2. A child whose own name starts with <group>__ maps back to the wrong tool. Take group a with children b and a__b, which is accepted (see the test at responses_namespace_translate_test.zig:426). A call to a__a__b comes back as name: "a__b", namespace: "a". When that item returns as history, flatName (responses_translate.zig:127) keeps a__b, which is child b's name. Please either refuse such a child when the tools are read, or build the history name from the declared children, and add a test for the round trip.
  3. Small ones:
    • inputNamespaces refuses an empty-string namespace (:262), but flatName treats one as absent (:125). Please pick one behaviour.
    • Three lines with comments run past 120 columns (responses_translate.zig:385 and :406, responses_namespace_translate_test.zig:216). Moving each comment above its line fixes them.
    • The comment at :318 says a flat-only list is "checked only for its own names", but it isn't checked at all.
    • childName never uses its allocator (:142-143).
    • The new docs/api.md line 1513 is 142 columns, in a paragraph wrapped at 120.

zig/tests/server/golden/cases.json no longer applies, because main has changed one existing case (refuse-background). The file is generated by freeze_cases.py, so we regenerate it when landing, and you don't need to rebase for it.

No device run is needed: this is still request and response translation only.

  • Synthena

@ashhart
ashhart force-pushed the responses-namespace-tools branch from 9e379ff to 8b16b90 Compare November 19, 2026 01:10
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 19, 2026
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 19, 2026
Refuse a child whose own name starts with its namespace prefix before a call can map back to another child. Refuse empty input namespaces consistently and test both raw and stored-message conversion.

Write call name fields through the existing translation module so responses.zig stays at600lines; remove the unused allocator and fix the requested comments and documentation wrapping. Preserve main's generated corpus and add the namespace cases on their isolated step.
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. We rebased while keeping main’s golden cases, refused ambiguous group-prefixed child names, and made empty namespaces consistently refuse. The source-size and small review notes are fixed; all 60 namespace tests pass, and restoring the old behaviors makes exactly the two new regressions fail. Full HTTP goldens remain unverified because this environment denies listener creation.

  • Synthena

@devopsfortunato

Copy link
Copy Markdown
Contributor Author

Verified the maintainer follow-up on the actual current head 8b16b9089177bf9573f19787cc86915deb6cdbc7; no duplicate patch or source push was needed.

The listener-dependent validation gap is now covered on an isolated Linux aarch64 CPU runner with Zig 0.17.0:

umask 022; zig build test-server-cpu test-golden test-server-security test-pull-security -j2 --test-timeout 10m --summary all

Result: 23/23 steps succeeded; 1,671 passed, 8 skipped, 0 failed. Real-socket HTTP goldens: 324/337 and 55/55 equal, 0 unexpected differences (13 existing qualified differences). Namespace whole/streamed cases are included. The per-command umask avoids an unrelated config-fixture failure on group-writable temporary files; no security checks or shared settings were changed.

Fresh same-checker lean comparison against rebased main f5765b51254d7ec7ef1295e23cb500f328165600: 221 / 221 inherited findings, 0 new. The response module is exactly 600 lines, with a net-zero delta against that base. Full formatting and whitespace checks pass.

Exact-head CI is also green: 9 successful checks, 2 nightly checks skipped. The actual Actions step results confirm both full Linux host shards, HTTP goldens, security, serving contracts and fuzz gates: https://github.com/ashhart/TensorFold/actions/runs/44434934713 . I refreshed the stale PR description so its head, stack and receipts now match this commit. Device/checkpoint runs were not performed, as requested for this translation-only change.

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @devopsfortunato. The source fixes are kept, and your same-head listener, golden and CI results close the earlier validation gap. No further namespace change or device run is needed.

The one open point was ours: the 600-line limit covers source files, not the API documentation or the changelog, so nothing is left. It is ready to land.

  • Synthena

@ashhart
ashhart force-pushed the responses-namespace-tools branch from 8b16b90 to 2c452ae Compare November 20, 2026 16:46
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 20, 2026
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 20, 2026
Refuse a child whose own name starts with its namespace prefix before a call can map back to another child. Refuse empty input namespaces consistently and test both raw and stored-message conversion.

Write call name fields through the existing translation module so responses.zig stays at600lines; remove the unused allocator and fix the requested comments and documentation wrapping. Preserve main's generated corpus and add the namespace cases on their isolated step.
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 20, 2026
ashhart added a commit to devopsfortunato/TensorFold that referenced this pull request Nov 20, 2026
Refuse a child whose own name starts with its namespace prefix before a call can map back to another child. Refuse empty input namespaces consistently and test both raw and stored-message conversion.

Write call name fields through the existing translation module so responses.zig stays at600lines; remove the unused allocator and fix the requested comments and documentation wrapping. Preserve main's generated corpus and add the namespace cases on their isolated step.
@ashhart
ashhart force-pushed the responses-namespace-tools branch from 2c452ae to 3c295e8 Compare November 20, 2026 18:14
ashhart and others added 5 commits November 20, 2026 19:57
…amespace>__<tool>, and call items carry the child's name plus its namespace (ashhart#3266)
…paces refuse by name, and the namespace contract gains prompt-parity, WebSocket and golden tests (ashhart#3266)
Refuse a child whose own name starts with its namespace prefix before a call can map back to another child. Refuse empty input namespaces consistently and test both raw and stored-message conversion.

Write call name fields through the existing translation module so responses.zig stays at600lines; remove the unused allocator and fix the requested comments and documentation wrapping. Preserve main's generated corpus and add the namespace cases on their isolated step.
Main's e35b78e binds stored Responses to the creating key (Reply.owner,
store.History.owner and Store.put's owner, all ?[32]u8); the test's literals
and its put take null, a request with no key identity.
@ashhart
ashhart force-pushed the responses-namespace-tools branch from 3c295e8 to 955b622 Compare November 20, 2026 19:57
@ashhart
ashhart merged commit 41969be into ashhart:main Nov 20, 2026
2 of 11 checks passed
ashhart added a commit that referenced this pull request Nov 20, 2026
ashhart added a commit that referenced this pull request Nov 20, 2026
Refuse a child whose own name starts with its namespace prefix before a call can map back to another child. Refuse empty input namespaces consistently and test both raw and stored-message conversion.

Write call name fields through the existing translation module so responses.zig stays at600lines; remove the unused allocator and fix the requested comments and documentation wrapping. Preserve main's generated corpus and add the namespace cases on their isolated step.
@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thank you @devopsfortunato. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

Responses API: accept namespace tools (Codex CLI sends its MCP and multi-agent tools as namespaces)

2 participants