Repository navigation
Restore bundled provider/model capabilities when installed runtime config predates them #108
Description
Context
Issue #105's real GLM qualification reached ollama_cloud through CodexHub with HTTP 200, but the first requested core tool was never called and the adapter had nothing to transform.
The retained telemetry shows that the request eagerly expanded 205 App/MCP namespace tools. A bounded A/B isolates the new blocker:
- Minimal real GLM request with the actual freeform
apply_patchschema plus five existing explicit lifecycle/search tools: returns one adaptedcustom_tool_callin about three seconds. - The same request plus 200 synthetic namespace tools: no
apply_patchcall before the eight-second bound. - Therefore Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105's response adapter is live; eager namespace-tool expansion is the current worker-qualification blocker.
Outcome
Add a generic provider/model capability for a deferred core tool surface so selected external models retain native non-namespace core tools while large App/MCP namespaces are not flattened eagerly. The policy must be configurable and reusable for future third-party models; do not hard-code GLM behavior into routing.
Scope
- Add a provider/model capability that selects the external tool-surface strategy; preserve the current strategy as the default.
- Configure Ollama Cloud GLM-5.2 to use the deferred-core strategy.
- Under that strategy:
- retain caller-advertised non-namespace core tools such as
shell_commandandapply_patch; - retain the bounded explicit
tool_searchand collaboration lifecycle tools already required by the compatibility path; - do not eagerly flatten App/MCP namespace declarations into hundreds of function tools.
- retain caller-advertised non-namespace core tools such as
- Preserve deterministic ordering and fail closed on malformed capability values.
- Emit sanitized telemetry with strategy, namespace declaration count, eager tool count, retained core count, and deferred count.
- Do not change official-model behavior, provider routing, retry/fallback, permissions, or Codex's advertised
apply_patchcontract. - Do not claim complete deferred discovery; native/full
tool_searchlifecycle remains 0.1.8 Beta3: Complete the generic client tool_search lifecycle #63.
Acceptance criteria
- A committed fast A/B harness reproduces the current failure: minimal surface green; 200-tool namespace surface red before the fix and green after the strategy is applied.
- GLM receives the configured deferred-core surface without the observed 205-tool eager expansion.
- Existing/default providers retain current eager namespace behavior.
- Minimal freeform
apply_patchstill reaches Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105's adapter and produces the paired custom/freeform call. - The exact Codex CLI qualification completes
shell_command -> apply_patch -> shell_command, changes the file exactly once, and retainsmodel=glm-5.2,upstream=ollama_cloud,route_mode=codexhubwith no Luna/Terra fallback. - Focused protocol/routing tests, full Python suite, report-only quality gate, and two-axis review pass.
Dependencies
- Blocks Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105's final real-worker acceptance.
- Reuses Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105's checkpointed adapter branch because both changes touch the same Gateway compatibility hotset; do not develop them concurrently.
- 0.1.8 Beta3: Complete the generic client tool_search lifecycle #63 remains the later full deferred-discovery qualification and does not block this core Worker slice.
Evidence boundary
The failed broad harness also exposed a separate shutdown/reporting weakness, but no orphan process remains. Process cleanup is not part of this Issue unless it prevents the committed bounded A/B harness.
Reopened runtime-configuration inheritance regression (2026-07-15)
The closed delivery above remains historical evidence. This section supersedes its completed acceptance for the regression below.
Problem and facts
- Restore bundled provider/model capabilities when installed runtime config predates them #108 / PR fix: budget external GLM tool surface #110 introduced the closed
tool_surface_strategycapability and bundled Ollama Cloudglm-5.2configuration fordeferred_core; the focused strategy tests pass. - A deterministic local comparison shows the bundled configuration resolves
ollama-cloud/glm-5.2todeferred_core, while an installed runtime configuration resolves it toeagerwhen the runtime predates the capability field. - In a fresh isolated GLM-5.2 request, the runtime-eager surface expanded 15 namespace declarations into 212 eager namespace tools (217 injected tools total), retained 13 core tools, skipped the requested first shell call, emitted a malformed
apply_patchcall, and failed closed.
Outcome
Restore generic missing-capability inheritance from bundled provider/model defaults when an installed runtime configuration predates a capability. Resolve the effective capability at the Python Gateway and the Rust/UI configuration persistence/export boundary. An explicit runtime model value wins. No routing behavior may depend on a GLM-specific branch.
Scope
- Inherit a bundled provider/model capability only when the corresponding runtime entry omits it, using the repository's existing provider/model resolution rules.
- Preserve explicit runtime model values, including an explicit
eageroverride, and preserve explicit runtime provider values under the existing precedence rules. - Carry the resolved, validated value through the Python Gateway and any Rust/UI configuration load, save, merge, or export boundary changed by the implementation.
- Add deterministic regressions for old runtime configuration, bundled-default resolution, and the resulting prepared external tool surface.
Non-goals
- No GLM-specific routing branch or caller/request override.
- No change to provider routing, retry/fallback, tool schema,
apply_patchvalidation, permissions, official-model behavior, or full deferred-discovery work. - Do not relax fail-closed validation of malformed capability values.
Acceptance criteria
- An installed runtime configuration missing the capability inherits the bundled provider/model default; qualified and unqualified Ollama Cloud GLM routes resolve to
deferred_core. - An explicit runtime model
eagervalue wins over the bundled model default; existing valid defaults and other provider/model behavior stay compatible. - Invalid configured capability values still fail closed before external I/O, and official requests remain unchanged.
- Deterministic tests prove the inherited strategy produces the deferred-core prepared surface rather than eager namespace expansion.
- Any changed persistence/merge boundary preserves explicit capability values without silently overwriting them.
- A fresh isolated GLM-5.2 acceptance completes
shell_command→apply_patch→shell_command, changes the target exactly once, and retainsmodel=glm-5.2,upstream=ollama_cloud, androute_mode=codexhubwith no official-model fallback.
Dependencies
Related: #105 owns the distinct apply_patch compatibility adapter. No dependency is added by this intake.
Expected hotset and parallel ownership
src-python/providers_config.pyand dedicated provider-capability load/persistence tests, includingtests/test_providers_config.py.- If needed for the configuration persistence/export boundary:
src-tauri/src/config.rs,src-tauri/src/models.rs, and only the affected frontend configuration persistence files/tests. - Prohibited/read-only for this Worker:
src-python/codex_proxy.py,src-python/config_overlay.py, andtests/test_routing.py. The existing deferred-core transformer is already proven; its error-mapping hotset is reserved for the distinct non-retryable adapter-error Issue.
Execution contract
Execution-Contract: v2
Verification-Class: strict
Verification-Commands: python -m pytest -q tests/test_providers_config.py; python -m pytest -q; python scripts/report_quality_gates.py (report-only; non-blocking). If the candidate changes the Rust configuration boundary: cargo test --manifest-path src-tauri/Cargo.toml. If it changes the frontend configuration boundary: cd frontend; npm run build; npm run test:ui-contract.
Manual-Evidence: One fresh isolated GLM-5.2 shell_command → apply_patch → shell_command acceptance with the exact route identity and no official-model fallback.
Architecture-Decision: resolved
Review-Owner: orchestrator
PR target: dev
Activity
NOirBRight commentedon Jul 12, 2026
ARCHITECTURE DECISION — approved with bounded refinements
tool_surface_strategy = eager | deferred_corecapability at provider and optional model override; model wins, absence resolves toeager. This is configuration capability, never a model-alias routing branch and never a caller/request override.build_external_model_indexandbuild_ollama_cloud_model_index:ollama-cloudis intentionally excluded from the generic index, so GLM would otherwise never receive the override.choose_upstreamonly copies the resolved capability;compatible_request_bodydefensively rejects an invalid internal value before upstream I/O. Official routing returns before this resolution.shell_commandand the freeformapply_patchschema. Strip raw namespace declarations in both modes.eagerretains the exact current flattening behavior;deferred_coreomits only nested functions that the current namespace flattener would add. Existing explicit functions remain.multi_agent_v1path. Preserve the Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105-basetool_searchexposure if present, but do not newly enable discovery behavior or claim 0.1.8 Beta3: Complete the generic client tool_search lifecycle #63.external_tool_surface_preparedevent after preparation. Definenamespace_declaration_countas raw eligible namespace declarations seen,eager_tool_countas nested functions actually flattened,retained_core_countas surviving caller-advertised non-namespace entries (a structural count, not an allowlist), anddeferred_tool_countas nested functions intentionally omitted. Counts only; no names, schemas, IDs, inputs, patch content, or credentials.mergeDiscoveredModelscurrently rebuilds from the discovered model and can drop prior-only fields). Configure only Ollama Cloudglm-5.2at model level; leave its provider and all other models on impliciteager.shell_command -> apply_patch -> shell_commandqualification with exact child/process ownership; no shared Desktop/Gateway configuration mutation and no broad process termination. Open the integration draft PR only after that real qualification passes.This Issue comment is the authoritative decision record for this bounded seam. No separate UI feature or full deferred-discovery architecture is authorized in #108.
NOirBRight commentedon Jul 13, 2026
ARCHITECTURE DECISION ADDENDUM — resolve eager compatibility and fail-closed ordering
This addendum resolves the conflict between clauses 3 and 7 of the prior decision. The Issue outcome (“preserve the current strategy as the default”) and exact legacy/default payload compatibility take precedence over the universal wording “strip raw namespace declarations in both modes.”
eageris the compatibility adapter and must reproduce the Adapt GLM-5.2 apply_patch function calls to the Codex freeform tool contract #105 baseline (cb1724de) for valid legacy/default external payloads. In particular:input.additional_toolsbyte/semantically unchanged;deferred_coreis the explicit opt-in normalization. It may promote the legacyadditional_toolscarrier, remove raw namespace declarations from the outgoing normalized tool surface, retain explicit non-namespace/core tools, and omit nested functions that eager would flatten. Only flatten-eligible declarations contribute to namespace/deferred telemetry counts; opaque namespaces are not reclassified as supported discovery.deferred_corenormalized surface and to declarations eager actually flattens. Do not use that assertion to change unrelated default/eager payloads.deferred_coreoutgoing request/response path proven byd3f5293b. Prove that with focused payload/replay equivalence and invalid-path tests, then rerun the relevant full gates and the narrowed Spec/Standards delta review. If the valid deferred request shape changes, stop and require a new bounded live qualification.Rationale: the
tool_surface_strategyseam earns its depth by containing variation behind one resolved capability. A new opt-in adapter must not silently rewrite the default adapter’s established external interface.WIP: checkpoint #105/#108 GLM qualification
NOirBRight commentedon Jul 13, 2026
Recovery plan for PR #110:
scripts/qualify-issue-108-glm-tool-surface.ps1(bounded retained-handle tree termination/cleanup and nested replay stdio isolation) andtests/test_smoke_scripts.py(a deterministic cleanup-bound regression).8b8d6265, tracks the matching remote tip, and no other registered worktree has this branch checked out.git diff --check; then push one focused commit and monitor all PR checks. No live GLM qualification or elevated sandbox run is planned.NOirBRight commentedon Jul 13, 2026
SCOPE CONFIRMATION — finish the Responses path
The accepted shortest path remains Ollama Cloud Responses. #108 continues to own only the provider/model
deferred_coresurface and its bounded qualification harness; #105 owns the exact apply_patch response/history compatibility contract.PR #110 must finish its CI repair and then satisfy the existing clean
shell_command -> apply_patch -> shell_commandResponses qualification. Do not add a generic Chat/custom-tool bridge, change provider routing, or broaden discovery behavior in this Issue. CC Switch is architecture evidence for the conditional #66 fallback, not a reason to rewrite this PR.NOirBRight commentedon Jul 13, 2026
Remediation plan for the remaining #105/#108 evidence gaps in PR #110:
scripts/qualify-issue-108-glm-tool-surface.ps1,tests/test_smoke_scripts.py, and one narrow sanitized fixture undertests/fixtures/for deterministic A/B and qualification-evidence replay/validation. No production source, routing/config, or type files will be edited.git diff --check, and a Spec/Standards delta review before pushing and monitoring all PR checks.Collision check: this branch is clean, tracks its remote at
aec5cb09, is checked out only in this worktree, and the current upstream-onlydevdiff has no paths.NOirBRight commentedon Jul 13, 2026
Resumed remediation plan:
Collision check: the assigned branch is the sole worktree, its published head is current, and the upstream-only dev path set is empty.
NOirBRight commentedon Jul 13, 2026
Harness-correction plan:
Collision check: the feature branch is clean, its remote matches HEAD, and the upstream-only dev path set is empty.
NOirBRight commentedon Jul 13, 2026
Readiness-harness correction plan:
Collision check: the branch is clean and synchronized at 0f1738a; the upstream-only dev path set is empty.
NOirBRight commentedon Jul 13, 2026
Follow-up evidence-review plan (current branch is clean; no write collision):
NOirBRight commentedon Jul 13, 2026
Final evidence-correction plan (branch is clean and synchronized; no collision):
No live qualification, production/config/routing, or prompt changes are planned.
NOirBRight commentedon Jul 13, 2026
Completed by PR #110, merged into dev at 2916190. The provider/model deferred_core capability, eager compatibility, GLM configuration, deterministic minimal/eager-200/deferred-200 A/B, exact four-request qualification evidence, full local gates, two-axis review, and all four GitHub checks passed.
[-]Budget external-model tool surfaces before GLM core execution[/-][+]Restore bundled provider/model capabilities when installed runtime config predates them[/+]NOirBRight commentedon Jul 15, 2026
Execution-Contract: v2
Verification-Class: strict
Verification-Commands:
Manual-Evidence: one fresh isolated GLM-5.2 shell_command → apply_patch → shell_command acceptance with model=glm-5.2, upstream=ollama_cloud, route_mode=codexhub, and no Official fallback; Orchestrator/human-owned after compatible integration.
Architecture-Decision: resolved
Review-Owner: orchestrator
Profile/Binding: debug — gpt-5.6-terra / max; effective binding and unrestricted filesystem/network with approval=never verified in preflight.
Base: dev@d03f97bd00f5f0c44815d94e444c8ac10050f299
Branch: codex/issue-108-provider-capability-inheritance
Owned hotset: src-python/providers_config.py; tests/test_providers_config.py; only proven necessary Rust/frontend configuration-persistence boundaries.
Prohibited hotset: src-python/codex_proxy.py; src-python/config_overlay.py; tests/test_routing.py.
Blockers: none. #134 may proceed in its disjoint hotset.
PR target: dev; use Closes #108 only for the complete reopened regression.
NOirBRight commentedon Jul 15, 2026
Completed by PR #136 and verified after compatible integration at
dev@6cf5a53617b26cd3fe2e32867f128351ab233ae4.Final fresh isolated Responses acceptance passed:
model=glm-5.2,upstream=ollama_cloud,route_mode=codexhubshell_command -> apply_patch -> shell_commanddeferred_coreremained active; apply_patch and apply_patch-history adapters both reportedadaptedcodexhub.issue108.qualification-evidence.v2, SHA-2568683827A445958815D99C2C320E7CF9BC580ACE9C522061EB7E351A348566D84The merged Debug portable resources for
providers_config.pyandcodex_proxy.pyalso matched the integrated source byte-for-byte. Acceptance is complete.