Repository navigation
Conversation
"inherit" and "coordinator" are resolution sentinels handled by resolve_swarm_spawn_selection, not agent-selected model overrides. They must pass validate_swarm_model_request regardless of the swarm_model_selection flag so LLMs that always send model:inherit do not block every spawn in default configs.
LiteLLM's /v1/models endpoint reports max_input_tokens but Jcode's catalog parser only checks context_window and context_length. This means models like deepseek-reasoner (1M window) get a 200k fallback budget, causing premature compaction. Also documents the second layer: Provider::context_window() calls context_limit_for_model_with_provider (static table) instead of context_limit_for_model_with_provider_and_cache, so even correctly parsed catalog data is bypassed. Issue 2 now has three defects: 2a (catalog parser), 2b (Provider bypasses cache), 2c (stall watchdog blind to long inference — the original watchdog finding, preserved).
[Medium impact] The PR appears safe to merge, with no outstanding findings. SummaryWorkers now inherit
Reviews (6) · Last reviewed commit: "style(swarm): rustfmt the use groups in ..." · Reviewed by Greptile |
osmanaksu
left a comment
There was a problem hiding this comment.
Review
Three commits, three concerns. The core logic is correct, but there are issues to address before merge:
1. Wrong issue reference (#2020)
Two doc comments reference :
crates/jcode-app-core/src/server/spawn_policy.rs:3—(#1165, #2020)crates/jcode-app-core/src/server/comm_session.rs:357—(#1165, #2020)
#2020 is "reasoning_effort none does not disable thinking on OpenAI-compatible gateways" — a closed, unrelated bug. The correct reference is #2153 (root session effort not propagated to spawned workers).
2. swarm_spawn_issues.md in the repo root
248 lines of issue-analysis documentation committed to the repo root. This is working material, not product code. Options:
- Remove it from the PR (keep it in the issue comments instead)
- Move it to
docs/swarm_spawn_issues.mdif it's meant to be a permanent reference
3. Correctness of the effort propagation (verified OK)
The three-level fallback chain is correct:
requested_effort → agents.swarm_effort → root swarm effort → "low"
is_swarm_effortgate ensures only the"swarm"sentinel triggers root inheritance (a root at"medium"does NOT propagate).swarm_root_reasoning_effort()readsagents.swarm_root_effortfrom config (default"low").- Config pin (
swarm_effort) wins over root inheritance — verified by the testresolve_swarm_spawn_effort(None, Some("high"), Some("swarm")) → Some("high"). - Non-swarm root effort is ignored — verified by
resolve_swarm_spawn_effort(None, None, Some("medium")) → Some("low").
4. Inherit sentinel fix (verified OK)
validate_swarm_model_request(None) → Ok(()) — confirmed in crates/jcode-config-types/src/lib.rs:677-678. Filtering out "inherit"/"coordinator" before validation is correct: these are resolution sentinels, not model overrides.
Suggested changes before merge
- Replace
#2020with#2153in both doc comments. - Remove
swarm_spawn_issues.mdfrom the PR (or move to docs/). - After rebase, verify CI passes (Build & Test, Format, Guardrails).
The swarm tool's CommunicateTool::execute called validate_swarm_model_request directly on params.model, rejecting 'inherit'/'coordinator' sentinels before they could reach resolve_swarm_spawn_selection. Only direct protocol requests (via spawn_swarm_agent) benefited from the server-side filter. Fix: apply the same is_inherit_sentinel filter at the tool entry point so agent-facing spawns with model:'inherit' work regardless of swarm_model_selection state. Also re-export is_inherit_sentinel at the server module level for cross-module access. Additionally: - Replace incorrect 1jehuang#2020 issue reference with 1jehuang#2153 (2 locations) - Remove swarm_spawn_issues.md working file from the PR - Add regression test for inherit sentinel bypass
|
✅ Fixed: tool-level inherit sentinel bypass applied (commit 4ea43ca).
Also applied:
Tests pass: |
resolve_swarm_spawn_effort now takes root_swarm_effort as an explicit
parameter instead of calling swarm_root_reasoning_effort() which reads
global configuration. This makes the function pure and the test isolated:
- Test now checks non-default values ("none", "medium") proving the
inheritance branch actually propagates the value
- Blank/whitespace root_swarm_effort correctly falls through to default
- Test no longer fails if JCODE_SWARM_ROOT_EFFORT is set to a non-default
Addresses code review feedback: the previous assertion passed even if the
inheritance branch was removed (both paths yield "low" default).
|
✅ Fixed both review issues (commits 4ea43ca + 4ee7e9d): Issue 1 (tool-level inherit bypass): Applied. Issue 2 (test depends on settings): Refactored.
Caller in |
|
✅ The E0364 compile error is already resolved in commit 4ee7e9d. |
The re-export chain required pub(crate) at the source (spawn_policy.rs) for server.rs to re-export it crate-wide. pub(super) caused E0364.
13d8778 to
0477295
Compare
server.rs and comm_session.rs are in the PR diff, so normalize the use-group ordering/rustfmt on those two files. The other three files that trip cargo fmt (reload.rs, util.rs, bash_tests.rs) are unchanged vs master and are left out to keep the diff focused.
Fixes #2148. Related: #2153, #2149.
Summary
Three focused swarm-spawn fixes, each independently testable. (The context-window documentation was drafted in this branch's history but removed before review to keep the PR focused on the code fixes — it does not add a file to the diff.)
Propagate root swarm effort to spawned workers (swarm: root session effort not propagated to spawned workers #2153). When the coordinator is in
swarmmode, its effective reasoning effort (fromagents.swarm_root_effort) now propagates to workers instead of falling back to the hardcoded"low"default. A coordinator withswarm_root_effort = "none"no longer silently re-enables thinking for its workers.Allow
model: "inherit"/model: "coordinator"whenswarm_model_selectionis disabled (swarm: tool description advertisesmodel/model: "inherit"but schema strips it; error does not name the config keys #2148). These are resolution sentinels handled byresolve_swarm_spawn_selection, not agent-selected model overrides. They must passvalidate_swarm_model_requestregardless of the flag. Previously, LLMs that always sendmodel: "inherit"blocked every spawn in default configs, and the tool-level validation was not the only place the sentinel needed bypassing.Config-free effort-resolution test. The new effort tests no longer depend on global configuration state, so they run reliably in the lib test harness.
Commits
ef4dc3c32a9bb2cb22d11910fa74ea43ca394ee7e9d540477295a38e2e4e43fChanges
1. Root effort propagation
resolve_swarm_spawn_effortinspawn_policy.rsgains a root-inherit fallback level:The root-inherit step checks
is_swarm_effort(root_effort)(only the"swarm"sentinel triggers it) and resolves via the already-resolvedagents.swarm_root_effortvalue, passed as a parameter to keep the function pure and testable without global configuration.spawn_policy.rs: addedroot_effort/root_swarm_effortparameters + the 3rd fallback level;is_inherit_sentinelispub(crate).spawn_model_selection.rs: addedreasoning_effort: Option<String>toCoordinatorSpawnIdentity.comm_session.rs: passes the coordinator's reasoning effort intoresolve_swarm_spawn_effort.provider.rs: addedsession_reasoning_effort()accessor.comm_session_effort_tests.rs: 5 new test cases.2.
model:inheritsentinel bypassThe inherit sentinels are filtered out before validation in both the session path (
comm_session.rs) and the tool-level path (communicate.rs), so a disabledswarm_model_selectionflag can no longer reject a validmodel: "inherit"/model: "coordinator"request.is_inherit_sentinelmatches"inherit"and"coordinator"case-insensitively.3. Net diff contains no documentation file
The
swarm_spawn_issues.mdanalysis (5N1K: catalog parser ignoresmax_input_tokens, Provider bypasses the catalog cache, stall watchdog blind to long inference) was written up on this branch to ground the fix, then removed (4ea43ca39) so the PR stays a focused code change. The analysis is preserved in the linked issue #2149 rather than merged as a repo doc.Tests
comm_session_effort_tests.rs: 5 new test cases (explicit SDK effort wins over config pin; config pin wins over root sentinel; root"swarm"+ no config inheritsswarm_root_effort; non-swarm root effort ignored; no root/no config →"low").comm_session_tests.rs:coordinator_identityhelper updated withreasoning_effort: None.communicate_tests/input_format.rs: tool-level sentinel-bypass coverage.Validation
cargo test -p jcode-app-core --lib comm_session: 37 passed, 0 failed.cargo clippy -p jcode-app-core --lib: clean.cargo fmt --check: clean on the two files this PR touches (server.rs,comm_session.rs). Three other files that tripcargo fmt(reload.rs,util.rs,bash_tests.rs) are byte-identical tomasterand unchanged by this PR, so they are left out to keep the diff focused.Related issues
model/model: "inherit"but schema strips it; error does not name the config keys #2148 (fixed here, fix Demo video upload #2): tool description advertisesmodelbut schema strips it.max_input_tokensignored, worker budget miscomputed, watchdog blind #2149 (not fixed here): context window not auto-discovered — analysis documented, no code change in this PR.stopis not idempotent and there is no batchteardown#2150:stopnot idempotent / no batchteardown(not fixed here).label#2151: lane todo named by full prompt, notlabel(not fixed here).await_membershas no blocking mode and swarm dependency IDs are not accepted bybg wait#2152:await_membersno blocking mode (not fixed here).