Repository navigation
fix: support Codex grammar-formatted custom tools - #378
franciscojavierarceo wants to merge 3 commits into
Conversation
Signed-off-by: Francisco Javier Arceo <[email protected]>
|
Thanks for working on this. This brings back the concern raised in the review of #158: copying a Lark or regex grammar into the function description while accepting any string as vLLM has grammar compilation and next-token masking, but this adapter does not connect the declared grammar to that machinery. Consequently, vLLM does not enforce this grammar through the proposed path. Prompt guidance may improve results, and Codex’s patch validation remains useful, but neither preserves the decoding guarantee. I understand the PR acknowledges this limitation; my concern is that it reintroduces the behavior previously rejected. For |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused adaptation reuses existing execution paths, has targeted regression coverage, and has no identified blocking issues.
Review effort: Balanced
Findings: None
What changed in this PR
Enables Codex’s grammar-formatted custom tools through the existing function-tool adapter, preserving client execution, streaming, and continuation behavior.
Changes:
- Accept typed text, Lark, and regex formats; carry grammars as model guidance, not constrained decoding.
- Enable native
apply_patchin launcher catalogs and update setup documentation. - Add regression coverage and actual-Codex HTTP/WebSocket smoke tests.
| File | Description |
|---|---|
| scripts/codex-smoke.sh | Runs the native patch smoke test. |
| scripts/codex_apply_patch_smoke.py | Checks actual Codex patch execution and continuation. |
| docs/guides/codex-desktop.md | Replaces the workaround and clarifies catalog routing. |
| docs/design/codex-integration.md | Documents grammar adaptation and verification. |
| crates/agentic-server/tests/responses_websocket_test.rs | Checks grammar preservation across continuations. |
| crates/agentic-server/src/agentic_harness.rs | Enables native patch tools in launcher catalogs. |
| crates/agentic-server-core/tests/tool_normalization_test.rs | Checks recorded grammar declarations normalize correctly. |
| crates/agentic-server-core/tests/custom_tool_test.rs | Verifies grammar-tool adaptation. |
| crates/agentic-server-core/src/types/tools/params.rs | Uses typed custom-tool formats. |
| crates/agentic-server-core/src/types/tools/mod.rs | Exports custom format types. |
| crates/agentic-server-core/src/types/tools/custom.rs | Defines formats and malformed-input tests. |
| crates/agentic-server-core/src/types/request_response.rs | Updates normalization documentation and tests. |
| crates/agentic-server-core/src/tool/normalize.rs | Clarifies custom-tool normalization documentation. |
| crates/agentic-server-core/src/tool/custom.rs | Adds grammar instructions and empty-definition validation. |
| ARCHITECTURE.md | Documents reuse of existing execution paths. |
| .rust-file-sizes.json | Lowers the parameter file’s size allowance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Merge main and preserve the grammar-formatted custom-tool adapter through the protocol-neutral ToolDeclaration path. Keep newer code-interpreter support and ratchet the merged file-size allowance. Validation: 1,356 server/core unit and focused integration tests passed (5 ignored); Clippy all targets with warnings denied; all pre-commit hooks; actual Codex 0.160.0 HTTP and WebSocket native-patch smoke tests. Signed-off-by: Francisco Javier Arceo <[email protected]>
Pin the harness job to Ubuntu 22.04 and verify user/network namespace loopback setup before building. Keep Codex's default workspace-write and network restrictions; isolate build caches by runner image. Require a completed native file-change event in addition to exact fixture contents. Validation: actual Codex 0.149.1 HTTP and WebSocket patch tests passed with the default sandbox; all pre-commit hooks passed. The original Ubuntu 24.04 failure was bwrap RTM_NEWADDR EPERM, before patch execution. Signed-off-by: Francisco Javier Arceo <[email protected]>
Summary
Investigates #358. This draft does not resolve it yet.
Codex declares native
apply_patchas a custom tool with a Lark grammar. The gateway currently rejects that declaration before inference, even though its model catalog enables the tool.inputadapter, custom-call streaming translation, and continuation path.apply_patchin the launcher-generated catalog and remove the documented shell-edit workaround. Clarify that llm-d deployments must route the Codex model-catalog request to Agentic API.file_changeevent as well as the expected file contents.mainand resolve conflicts while preserving itsToolDeclarationAPI and code interpreter support.Grammar is model guidance, not upstream constrained decoding. Codex still parses and validates patches and applies its sandbox and approval policy. This adds no separate streaming or tool-execution path.
Test Plan
f5fbbbepass, including Rust, Python, pre-commit, wheel builds, and the Claude Code/Codex harness job. Deployment and publication jobs are skipped as expected for this PR.main: 1,356 server/core tests passed (5 ignored); server/core Clippy passed with all targets and warnings denied. All repository pre-commit hooks passed, including rustfmt and the Rust file-size checks.apply_patchsmoke passed over HTTP and WebSocket with Codex0.160.0after the conflict resolution.0.149.1, the full localscripts/codex-smoke.shsuite passed: text, image requests/capture checks, and native patch execution plus continuation over HTTP and WebSocket. The default sandbox remained enabled. The updated harness also passed on GitHub's Ubuntu 22.04 runner.0.155.0-alpha.9.2.Qwen/Qwen3.8-27B-FP8on vLLM 0.29.0: HTTP and WebSocket edit/resume runs passed add, update, rename, delete, Unicode, backslash, and matching custom-call/output checks. These live runs were not repeated for the latest CI-only change.No replay cassettes were edited; existing captures are reused for normalization assertions, and the new end-to-end smoke uses a synthetic upstream. These checks validate the exploratory adapter's execution path, not grammar enforcement or a dedicated Responses
apply_patchadapter.