Skip to content

fix(api): hoist message-name omit/validate before tools passthrough - #623

Closed
cursor[bot] wants to merge 12 commits into
mainfrom
cursor/bc-0264e185-4eb5-4824-9123-9c26f9754c29-724c
Closed

fix(api): hoist message-name omit/validate before tools passthrough#623
cursor[bot] wants to merge 12 commits into
mainfrom
cursor/bc-0264e185-4eb5-4824-9123-9c26f9754c29-724c

Conversation

@cursor

@cursor cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Summary

  • Treat chat message name null/empty/whitespace as omit-equivalent (same as fix(api): treat chat message name empty/whitespace as omit #614 4f84700).
  • Hoist _omit_or_validate_message_name / _validate_chat_message_name before tools proxy_completion so non-string, over-long, and charset-invalid names cannot smuggle on the tools path.
  • Pop blank names in place so omit is real, not accept-only.
  • Tools-path HTTP tests plus _validate_messages omit assertions. Docs: docs/rest_api_design.md, docs/papers/README.md (APA 7th OpenAI chat-completion citation), docs/architecture.md.

Why this PR

#614 unique tip is sound on the orchestration helper, but tools passthrough still returned 200 for name: 123 / 65-char / bad charset. Buyers must get invalid_message_name on both paths.

Test plan

  • python3 tests/test_message_name_empty_omit_http_honesty.py
  • python3 tests/test_message_name_tools_passthrough_http_honesty.py
  • python3 tests/test_chat_message_name_http_honesty.py
  • python3 tests/test_message_name_null_noop_http_honesty.py
  • python3 tests/test_paper_contracts.py
  • python3 tests/test_api_contract.py
  • python3 tests/test_conventions.py
  • python3 tests/test_self_check.py
  • CI Full unit + Semgrep

Landing

Prefer this hoist over merging #614 as a 142-file stack. Independent non-author APPROVE required. Do not merge in parallel with other honesty-stack PRs onto main.

Open in Web View Automation 

seonghobae and others added 12 commits August 16, 2026 21:18
…closed otherwise

Chat history: message-level audio and legacy function_call are null/empty omit
no-ops; non-empty fail closed with named errors (including tools passthrough).
Tip substrate from #577 assistant refusal/annotations honesty. Local full unit:
940 passed.
…ed otherwise

OpenAI fine-tune style message weight is not applied on this gateway.
Accept null/0/1 as honest no-ops; reject other types and values with
invalid_message_weight. Tip substrate from #578. Local full unit: 943 passed.
…ion role

Reject unsupported message keys with named unknown_message_fields (not silent
strip or tools-passthrough smuggle). Reject legacy function role with
invalid_message_role migration to tool. Tip substrate from #579. Local full
unit: 947 passed.
OpenAI partial-assistant prefix flag is not applied on this gateway.
null/false are honest no-ops; true and non-booleans fail closed with
invalid_message_prefix. Tip substrate from #580. Local full unit: 950 passed.
…therwise

Named invalid_max_tool_calls on /v1/chat/completions instead of opaque
unknown_fields. Aligns with Responses max_tool_calls honesty; gateway has
no multi-step tool loop.
…losed otherwise

Legacy /v1/completions treated max_tool_calls as unknown_fields. Accept the
key for named invalid_max_tool_calls (null/empty/whitespace omit-equivalent),
matching chat/Responses honesty so SDKs get a clear migration path.
SDK clients often send include_usage/include_obfuscation as JSON null.
Drop null flag values before validation so null (and null+false mixes)
match omit / all-false no-ops on chat, Completions, and Responses.
True flags remain fail-closed with invalid_stream_options.
…or Responses parallel true

SDK optional defaults often send function.strict and json_schema.strict as
null — treat as omit rather than type errors. Align Responses
parallel_tool_calls=true with chat by requiring a non-empty tools array.
SDK optional defaults often send description and parameters as JSON null.
Treat null as omit rather than type errors; non-null non-string/object
values remain fail-closed with invalid_tools.
OpenAI-style tool descriptions are at most 1024 characters. Over-long
descriptions fail closed with named invalid_tools so SDKs never believe a
truncated description was accepted.
SDK optional participant name blanks ("" / whitespace) are omit-equivalent
like JSON null. Non-string, over-long, and invalid charset names remain
fail-closed with invalid_message_name.
Blank SDK name defaults are popped in place so omit is real on both
orchestration and tools paths. Non-string, over-long, and invalid
charset names fail closed with invalid_message_name before proxy.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@cursor
cursor Bot requested a review from seonghobae August 16, 2026 16:06
@seonghobae
seonghobae marked this pull request as ready for review August 16, 2026 16:11
@seonghobae
seonghobae enabled auto-merge (squash) August 16, 2026 16:11
@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown
Author

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Unique tip is sound — do not merge the stack yet

3f3f8ef does what the title claims. _omit_or_validate_message_name pops None / "" / whitespace in place, including Unicode whitespace via str.strip(). _validate_chat_message_name runs at server.py:3609 on the same body that proxy_completion forwards at :3647. Non-string, over-long, charset-invalid, and non-blank role=tool names fail closed with invalid_message_name on both orchestration and tools/passthrough paths (including response_format / tool_choice triggers).

Helper tests prove the pop. Tools-path HTTP tests prove the 400 cases. Docs (docs/rest_api_design.md, docs/architecture.md) and the APA 7th OpenAI chat-completion cite in docs/papers/README.md match the omit/fail-closed contract.

Next action for the landing reviewer

  1. Prefer this hoist over #614. Do not merge #614.
  2. Independent non-author APPROVE is still required (reviewer seonghobae is already requested).
  3. Do not merge this 147-file honesty stack onto main in parallel with #621, #624, #625, #628, or #629.
  4. Pending GitHub Checks are not a product blocker. A concrete failing job is.

Residual (non-blocking)

  • Tools-path HTTP 200 cases still prove accept, not omit — _mock_raw does not echo messages.
  • Charset predicate is str.isalnum() while docs/error text say [a-zA-Z0-9_-].
  • _validate_chat_message_name skips non-list / non-dict messages (pre-existing tools-path shape gap). Do not widen this PR to fix that.

Do not open a third empty-name PR. Land this unique tip after an independent APPROVE, then rebase dependents onto the merge result.

Open in Web View Automation 

Sent by Cursor Automation: Fix Issues

"tools": _TOOLS,
},
)
assert status == 200, (value, body)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

HTTP 200 here still only proves accept. _mock_raw echoes model / tools / tool_choice / sampling keys, not messages, so this test cannot see whether blank name was popped from the proxied body.

Helper tests already prove the in-place pop. If you want omit-honest HTTP coverage, echo messages from the mock and assert "name" not in body["echo"]["messages"][0] on these 200 cases.

Do not treat this as a tools-path smuggle. The hoist at server.py:3609 is sound.

"tools": _TOOLS,
},
)
assert status == 200, body

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same accept≠omit gap for blank name on role=tool. Status 200 is necessary; it is not sufficient to prove the key was stripped before proxy_completion.

Keep the 400 cases (123, 65-char, bad name!, ZWSP, non-blank tool-role name). Those already fail closed with invalid_message_name.

"invalid_message_name",
"message name must be at most 64 characters",
)
if not all(ch.isalnum() or ch in "_-" for ch in msg_name):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

str.isalnum() is wider than the documented [a-zA-Z0-9_-] class and the error string on the next lines. Unicode letters such as café are accepted and forwarded. This predicate was hoisted as-is from #614 — not a new tools-path hole.

Pick one contract: re.fullmatch(r"[A-Za-z0-9_-]+", msg_name) to match the docs, or change the docs/error text to Unicode alphanumeric plus _/-. Add a café case either way. Do not widen this PR to re-validate full message shape.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687.

  • Head SHA: 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687

  • Workflow run: 32138303634

  • Workflow attempt: 1

Coverage evidence

Coverage evidence job did not run or did not publish coverage evidence.

Changed-File Evidence Map

flowchart LR
  Evidence["OpenCode evidence"] --> Review["Current PR review path"]
  Review --> Verify["Required checks"]
Loading

@opencode-agent

opencode-agent Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687
  • Workflow run: 32148163640
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687.

  • Head SHA: 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687

  • Workflow run: 32148163640

  • Workflow attempt: 1

Coverage evidence

Coverage evidence job did not run or did not publish coverage evidence.

Changed-File Evidence Map

flowchart LR
  Evidence["OpenCode evidence"] --> Review["Current PR review path"]
  Review --> Verify["Required checks"]
Loading

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687.

  • Head SHA: 3f3f8ef22d886eba39d2fe3d4a0b8cf10101f687

  • Workflow run: 32148163640

  • Workflow attempt: 1

Coverage evidence

Coverage evidence job did not run or did not publish coverage evidence.

Changed-File Evidence Map

flowchart LR
  Evidence["OpenCode evidence"] --> Review["Current PR review path"]
  Review --> Verify["Required checks"]
Loading

@seonghobae seonghobae closed this Aug 20, 2026
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.

2 participants