Skip to content

fix(kernel): resolve team/delegate model pins through the config accessor - #5405

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:oh-kernel-review-followups
Aug 5, 2026
Merged

fix(kernel): resolve team/delegate model pins through the config accessor#5405
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:oh-kernel-review-followups

Conversation

@senamakel

@senamakel senamakel commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

Problem

#5396 merged with 18 unresolved threads. Four were real defects in the config seam; the rest were documentation drift and lint.

The two model-pin bugs share a shape: the mapper copied raw Option<String> fields instead of going through the accessor that owns the semantics.

  • TeamModelConfig::model_for_role trims, drops empty strings, and falls back across the lead_model/agent_model pair — its own doc says "callers fall back across the pair so configs can specify only one tier without breaking routing". apply_team_models did none of that, so a team pinning only lead_model ran its subagents on the global default rather than the model the user chose for that team.
  • DelegateAgentConfig::model is a bare String. apply_delegate assigned it unchecked, so model = "" replaced a working session model with the empty string and failed at dispatch rather than at config load.

The coverage gap was pointed out with unusual precision and is worth restating: compact_context and tool_result_budget_bytes were mapped but unfalsifiable. default_config_maps_to_the_crate_defaults compares against TurnConfig::default(), so a field left at the crate default still passes; per_section_mappers_agree_with_the_composed_one asserts s.turn == turn_config_from(&c.agent), which compares the mapper against itself. A dropped assignment for either field would have stayed green.

Solution

  • apply_team_models resolves both roles through model_for_role(true/false).
  • apply_delegate trims and ignores a blank pin, warning rather than silently substituting.
  • turn_limits_come_from_the_agent_section sets both previously-uncovered fields away from their defaults, with a comment naming why the other two tests cannot catch them.
  • AgentConfig::session_shadow_reads' doc now lists disabled and notes case-insensitivity, matching env_kill_switch_engaged, which accepts 0|false|no|off|disable|disabled. The implementation was right and the config doc was incomplete — the reviewer offered "or remove an unsupported value", but the value is supported.
  • plan-agents.md §Phase 4: integration_runtime_config: Option<Config>runtime_config: Option<Arc<Config>> landed in feat(kernel): host capability adapters, config seam, and the Phase 2 transcript soak #5396, so the plan was describing completed work as a future blocker. Rewritten, and the two crate-side blockers found during that review are now linked.

Behaviour change worth flagging: a_team_pinning_only_one_tier_leaves_the_other_on_the_default asserted the buggy behaviour and has been replaced by a_team_pinning_only_one_tier_applies_it_to_both. If the old semantics were intentional, this is the test to argue about — but TeamModelConfig's own doc says otherwise.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) — a_team_pinning_only_one_tier_applies_it_to_both, a_blank_team_pin_does_not_displace_the_default, a_blank_delegate_model_keeps_the_session_default, plus the extended turn-limits assertions.
  • Diff coverage ≥ 80% — deferring to the CI gate; the change is small and test-heavy.
  • Coverage matrix updated — N/A: no feature rows added, removed, or renamed.
  • All affected feature IDs from the matrix are listed under ## RelatedN/A: no matrix rows touched.
  • No new external network dependencies introduced — N/A: no network code.
  • Manual smoke checklist updated — N/A: no release-cut surface touched.
  • Linked issue closed via Closes #NNNN/A: follow-up to a merged PR, no tracking issue.

Impact

Config mapping only, and the adapters remain unwired (Phase 4 repointing is still blocked), so nothing changes at runtime today. The team-pin fix changes which model a team's subagents would resolve to once the seam goes live.

cargo fmt --check, cargo clippy --lib -D warnings, and the full lib suite (12820 / 0) are clean.

One caveat I would rather state than omit: the first full-suite run in this fresh worktree reported 3 failures whose names I did not capture, and four subsequent runs were clean. It looks like first-run state initialisation rather than these changes — they touch only config mapping and docs — but I could not reproduce it to confirm, so I am not claiming it away.

Related

Follow-up to #5396. Two crate-side blockers surfaced by that review are filed upstream:

Summary by CodeRabbit

  • Bug Fixes

    • Improved team model selection with trimming, empty-value filtering, and fallback between configured tiers.
    • Blank delegate model settings no longer override the session’s selected model.
    • Added coverage for model selection and context/tool-result budget scenarios.
  • Documentation

    • Clarified configuration planning and model-resolution prerequisites.
    • Documented that setting shadow reads to disabled, as well as other falsy values, disables them.
    • Improved Markdown syntax highlighting for the policy flow diagram.

senamakel and others added 8 commits August 5, 2026 13:02
Checkpoint of work in progress, touching src/openhuman/config/schema/agent.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/config.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/config.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/config.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/config.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/config.rs.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching 2 files: docs/specs/kernel.md,docs/specs/plan-agents.md.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching docs/specs/plan-agents.md.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel requested a review from a team August 5, 2026 10:23

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

senamakel has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes update team and delegate model-pin handling, expand related tests, revise agent migration planning, label a Markdown code fence, and document disabled as a falsy shadow-read value.

Changes

Model pin resolution

Layer / File(s) Summary
Model pin behavior
src/openhuman/agent/tinyagents/config.rs
Team pins now trim values, ignore blanks, and fall back across tiers. Blank delegate overrides preserve the session model and emit a warning.
Model pin validation
src/openhuman/agent/tinyagents/config.rs
Tests cover tier fallback, blank pins, compact-context settings, and tool-result budgets.

Agent planning updates

Layer / File(s) Summary
Agent plan status
docs/specs/plan-agents.md
The plan updates heading levels, runtime configuration references, migration status, and upstream adapter blockers.

Documentation clarifications

Layer / File(s) Summary
Documentation wording
docs/specs/kernel.md, src/openhuman/config/schema/agent.rs
The kernel diagram fence is labeled text. The shadow-read documentation includes disabled as a falsy value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: al629176

Poem

A rabbit checks each model pin,
Trims the blanks and lets hope in.
Plans grow clear and docs align,
Budgets test the flow just fine.
Hop, hop—cleaner paths now shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: resolving team and delegate model pins through the kernel configuration accessor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/agent/tinyagents/config.rs`:
- Around line 151-162: Add verbose, grep-friendly diagnostics in
src/openhuman/agent/tinyagents/config.rs:151-162 around the model_for_role-based
team-pin resolution, logging the resolution result and whether lead and subagent
pins were applied after fallback without model values; in
src/openhuman/agent/tinyagents/config.rs:173-186, log entry and successful
completion of the non-blank delegate model override, also excluding model
values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e51b4e5d-702b-4a2b-9daa-ab9c2e806776

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfa6f2 and fd3eb31.

📒 Files selected for processing (4)
  • docs/specs/kernel.md
  • docs/specs/plan-agents.md
  • src/openhuman/agent/tinyagents/config.rs
  • src/openhuman/config/schema/agent.rs

Comment on lines +151 to +162
// Resolve through `model_for_role` rather than copying the raw options.
// That helper owns three behaviours this mapper must not re-derive: it
// trims, it drops empty strings (so a blank pin cannot displace a valid
// default), and it falls back across the pair — a team that sets only
// `lead_model` means that model for *both* tiers. Copying the fields
// directly left the unset tier on the global default, which is a different
// model from the one the user configured.
if let Some(lead) = pins.model_for_role(true) {
session.lead_model = Some(lead.to_string());
}
if let Some(agent) = pins.agent_model.as_ref() {
session.subagent_model = Some(agent.clone());
if let Some(agent) = pins.model_for_role(false) {
session.subagent_model = Some(agent.to_string());

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add diagnostics for the changed model-pin flows.

Both flows change session model state but do not provide complete branch diagnostics.

  • src/openhuman/agent/tinyagents/config.rs#L151-L162: log the team-pin resolution result and whether lead and subagent pins were applied after fallback.
  • src/openhuman/agent/tinyagents/config.rs#L173-L186: log entry and successful completion of a non-blank delegate model override.

Do not log model values.

As per coding guidelines, “Add verbose, grep-friendly diagnostics for new or changed flows, including entry/exit, branches, external calls, retries, state transitions, and errors; never log secrets or full PII.”

📍 Affects 1 file
  • src/openhuman/agent/tinyagents/config.rs#L151-L162 (this comment)
  • src/openhuman/agent/tinyagents/config.rs#L173-L186
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/agent/tinyagents/config.rs` around lines 151 - 162, Add
verbose, grep-friendly diagnostics in
src/openhuman/agent/tinyagents/config.rs:151-162 around the model_for_role-based
team-pin resolution, logging the resolution result and whether lead and subagent
pins were applied after fallback without model values; in
src/openhuman/agent/tinyagents/config.rs:173-186, log entry and successful
completion of the non-blank delegate model override, also excluding model
values.

Source: Coding guidelines

@senamakel
senamakel merged commit d9d03af into tinyhumansai:main Aug 5, 2026
24 checks passed
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.

1 participant