Repository navigation
Description
Status
Accepted on 2026-07-28.
ApplyPatch and Code Mode will ship as independent capabilities over one effective per-run tool surface. Code Mode will execute JavaScript in a short-lived Node child process outside the Maka process. Node's permission model is defense in depth; the child must also run under the current session's existing OS sandbox or a stricter equivalent.
The current tool surface remains the default until the capability-specific validation gates pass.
Problem
Maka currently gives GPT models a mostly generic direct-tool surface, even when their coding-agent training favors different protocols. In one controlled GPT-5.6 Sol DeepSWE pair, both runs passed, while Maka used 30.2 minutes, 5.36M tokens, and 133 environment actions versus Codex CLI's 18.2 minutes, 2.80M tokens, and 38 actions; a second pair showed the same time direction.
The sample is too small to assign causality, but it is sufficient to test two independent variables:
- whether a GPT-compatible ApplyPatch editing surface outperforms Edit/Write; and
- whether
exec/waitorchestration outperforms direct-only tool calling.
Decision
Extend the effective per-run tool surface from #1493 with one tool-protocol compatibility profile:
| Axis | Values |
|---|---|
| Editing | Current Edit/Write, ApplyPatch |
| Orchestration | Direct, CodeMode, CodeModeOnly |
The profile is a projection over the same effective MakaTool[], deferred activation state, and ToolRuntime. It is not a second registry, tool catalog, permission path, or execution runtime.
Every axis has an explicit per-run override. Model-specific defaults may change only after the corresponding validation gate passes.
Candidate defaults:
| Model profile | Editing | Orchestration |
|---|---|---|
| GPT-5 profiles validated for patch training | ApplyPatch | Direct |
| GPT-5.6 Sol/Terra | ApplyPatch | CodeModeOnly |
| Other models | Current surface | Direct |
These are rollout candidates, not active defaults.
Delivery
- feat(runtime): add GPT-compatible ApplyPatch editing projection #1552 — add the GPT-compatible ApplyPatch editing projection and validate it against Edit/Write.
- feat(runtime): add confined CodeMode exec cells #1553 — add brokered
exec/waitin CodeMode while retaining direct ordinary tools.
CodeModeOnly is an accepted follow-up boundary, but its issue will be opened only after CodeMode lands so its PR can start flat from the latest main.
#1493 is a prerequisite for both current slices and the later CodeModeOnly delivery. Each delivery must extend its effective-surface result rather than create a parallel name list or binding path.
ApplyPatch and Code Mode remain independently selectable and independently revertible. ExploreAgent removal is not part of these deliveries; open separate work only when a concrete cleanup requirement exists.
Shared invariants
Tool authority
- The effective per-run tool surface from refactor(runtime): project one effective product-tool surface per run #1493 remains authoritative.
- Every nested tool call re-enters the existing
ToolRuntime; Code Mode must not callMakaTool.impldirectly. - Existing validation, deferred gating, permission checks, sandbox policy, abort, limits, durable T1/T2 facts, telemetry, artifacts, and UI activity remain in force.
- Provider history contains only the
exec/waitcalls issued by the model. Nested calls are durable runtime facts linked to their parentexec, but are never replayed as provider function calls or results.
Code Mode process boundary
- Each
execcell runs in a short-lived Node child process, not Maka's main process and not a persistent sidecar. - A cell receives no direct filesystem, process, module, worker, or network authority.
- Node
--permissionrestrictions provide defense in depth. The OS sandbox remains the authority ceiling; if Maka cannot enforce that ceiling, Code Mode fails closed. - A cell that completes within the initial yield window returns directly. Otherwise
execreturns an opaquecell_id, and top-levelwaitcollects more output or terminates it. - Cells do not persist across turns or application restarts and do not provide REPL state.
Projection
| Mode | Provider top level | Inside exec |
|---|---|---|
| Direct | Active ordinary tools | Unavailable |
| CodeMode | Active ordinary tools plus exec / wait |
Active nestable tools |
| CodeModeOnly | exec / wait plus direct-only exceptions |
Active nestable tools |
AskUserQuestion, Agent/Team tools, exec, and wait are direct-only. Ordinary product and supplemental tools are nestable by default. load_tools is nestable; inside a cell it updates the existing activation state and exposes newly loaded tools to that same cell.
Validation and rollout gate
- ApplyPatch A/B holds model, prompt, task, executor, and orchestration mode constant.
- Code Mode A/B holds the editing surface constant and compares Direct, CodeMode, and CodeModeOnly.
- Contract tests cover editing replacement, the projection matrix, top-level and nested admission, same-cell
load_tools, nested-call durability without provider transcript pollution, cell ownership/lifecycle, and the sandbox authority ceiling. - No model default changes unless correctness does not regress and provider steps, context use, or wall time improve consistently.
- Every enabled default retains an explicit rollback to the previous surface.
Non-goals
- Shipping ApplyPatch and Code Mode in one implementation PR.
- Removing ExploreAgent.
- Adding provider-hosted tools.
- Building a general-purpose scripting platform or persistent REPL.
- Requiring provider-native programmatic calling for V1.
Activity
somewan820 commentedon Jul 23, 2026
@Astro-Han I'd like to take this issue.
Astro-Han commentedon Jul 23, 2026
Hi @somewan820, #1383 is closed for now until #1381 finishes. Would be happy to initial this issue once #1381 is done!
[-][RFC] Native-first Programmatic Tool Calling[/-][+][RFC] GPT tool-protocol compatibility: ApplyPatch and Code Mode[/+]Astro-Han commentedon Jul 27, 2026
#1381 is complete through #1390, #1417, and #1425, so the original blocker is gone. Reopening and revising this RFC based on the newer GPT-5.6 head-to-head evidence and the current effective-tool-surface work in #1493.
The revision changes three assumptions: it treats ApplyPatch and Code Mode as independent axes of one model compatibility profile, targets the observed local
exec/waitprotocol instead of requiring provider-native programmatic calling first, and keeps their implementation and evaluation deliveries separate.[-][RFC] GPT tool-protocol compatibility: ApplyPatch and Code Mode[/-][+]GPT tool-protocol compatibility: ApplyPatch and Code Mode[/+]feat(runtime): add GPT-compatible ApplyPatch editing projection
feat(runtime): add GPT-compatible ApplyPatch editing projection
Astro-Han commentedon Aug 26, 2026
Status revision — 2026-08-26
The 2026-07-28 acceptance still holds on its core point: tool-protocol compatibility is a projection over one effective per-run tool surface, not a second registry, catalog, permission path, or execution runtime. Everything below revises what has changed since.
1. The editing axis is retired
#1552 was closed as superseded by #2532, which replaced the design with the AI SDK native
openai.tools.applyPatch(), registered only for documented Apply Patch models on native OpenAI Responses. #2532 removed the editing-protocol projection outright — no custom parser, no per-run editing override, no provider fallback. Desktop surfacing was tracked and closed in #2601.Editing is therefore no longer an axis of this profile. It is an automatic model-capability gate (
provider-registry.ts,applyPatchProtocol). The two-axis table above should be read as one axis, and this issue's title is now wider than its scope — I propose retitling it to Code Mode only.2. Code Mode's execution model changed
This issue accepted "a short-lived Node child process outside the Maka process", with Node's permission model as defense in depth and the child running under the session's existing OS sandbox.
What shipped is in-process QuickJS via
@ai-sdk/code-mode'sexperimental_runCodeMode(#2549, wrapped bypackages/code-mode/src/quickjs.ts; remaining cleanup in #3213). The isolation premise of the accepted decision no longer describes the implementation. #2466 required any such replacement to preserve ToolRuntime permissions, suspension, abort, durability, recovery, hidden replay, and Desktop/CLI/Headless packaging; that preservation should be stated item by item before the path becomes user-reachable.3. The validation gate ran in reduced form and returned "do not roll out"
The 89-task paired TB2.1 evaluation was never executed. #2466 closed with the plan deliberately revised: a 10-task single-repetition diagnostic, equal verifier outcomes across Direct, Self, and QuickJS (7/10 each), establishing neither equivalence nor non-inferiority — and establishing that automatic rollout was not justified.
Same pass rate at roughly 1.7x steps, 3.7x tool calls, and 2x tokens.
4. Candidate defaults are withdrawn
The candidate table above (GPT-5.6 Sol/Terra -> ApplyPatch + CodeModeOnly) is superseded. #2466's decision is to retain Code Mode as a supported, default-off capability and to enable it automatically for no model on the current evidence.
Subsequent internal A/B work narrows this further: current models largely do not use Code Mode well — DeepSeek V4 Flash does not — and gpt-5.6-sol is the only model observed to use it effectively, while broad adoption of that family is not currently planned.
Taken together: there is no rollout hypothesis today, and Code Mode's measured cost is roughly double for no measured benefit outside one model family.
5. CodeModeOnly
Recorded here as an accepted follow-up boundary whose issue would open once Code Mode landed. Code Mode landed in August; no issue was opened, and
ToolModeinpackages/core/src/tool-mode.tsis'direct' | 'code_mode'with no third value. This needs an explicit call: open it, or retire the value from this decision.Current state
toolMode = 'code_mode'(chore(runtime): Code Mode is on @ai-sdk/code-mode now — delete superseded custom scaffolding, consolidate byte counting, fold the package into runtime #3213). Selecting it addsexecalongside the existing direct tools (projectToolModePlan); it is not CodeModeOnly. feat(desktop): add a CodeMode preference #2578 / feat(desktop): add a CodeMode preference #3850 is the producer that would make it user-selectable.Open decisions
Delivery — updated
AI use: Claude Code assisted with source and issue investigation; the analysis and conclusions are my own.
github-actions commentedon Sep 26, 2026
This issue has had no human activity for 30 days and has been marked stale. It will be closed in 30 days unless someone comments.
If the issue is still current, please confirm it against the latest
mainand add any information that would help move it forward. Assigned issues and issues labelledpinnedare exempt from this policy.github-actions commentedon Oct 26, 2026
This issue has been closed because it received no human response during the 30-day grace period. This is not a judgement on the value of the report.
If the issue still applies to the latest
main, please comment with updated evidence so a maintainer can reopen it, or open a follow-up issue with the missing information.