Apply agent profile reasoning/temperature frontmatter (#828) - #829
Merged
Conversation
) The reasoning and temperature frontmatter keys were parsed into AgentDef but never read. Wire them into the main loop: - /agent <name> applies the profile's reasoning via session.effort_override (the same mechanism /effort uses, so rebuilds keep it sticky), capturing the pre-profile override in ContextFiles.effort_before_agent — the effort sibling of route_before_agent. /agent off restores it. - The profile wins over a live /effort override at activation; a later /effort overrides it; /agent off restores the pre-profile value, mirroring how the model restore discards a mid-profile /model. - An unrecognised reasoning value warns and leaves effort untouched; the switch proceeds (fail-soft, matching /effort's unknown-level handling). - temperature is consulted from the active agent layer at agent build time (profile > CLI > config), so /agent's rebuild applies it and /agent off's rebuild falls back automatically. Same clamp/warn as before. - Subagent path unchanged (still model + prompt only); docs updated: the key table now lists all seven /effort levels and the new semantics. Verified end-to-end with the wire dump: turn under the profile flips to model=claude-haiku-4-5 reasoning=false, /agent off returns to claude-sonnet-5 reasoning=true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #828. Implements option 1 from the issue, as requested.
What was wired
Both keys, by two mechanisms — the codebase offers a different hook for each.
reasoning—/agent <name>parsesdef.reasoningwith the same parser/effortuses and writes it tosession.effort_override, the same field/effortwrites, so the existing re-application on rebuild makes it stick. The pre-profile override is captured in a neweffort_before_agent: Option<Option<ThinkingLevel>>on the context — the effort sibling of the existingroute_before_agent— and/agent offtakes and restores it. The switch summary line gains· effort <level>.temperature— there is no runtime setter onAnyAgent, sobuild_agent_innernow consults the agent layer ahead ofcli.resolve_temperature(cfg):/agentrebuilds the agent and/agent offclears the layer before rebuilding, so apply and restore both fall out with no capture state, and a profile omitting the key falls through untouched. The existing clamp and warn are unchanged.Decisions
/effort: the profile wins at activation (it displaces a live/effort max); a later/effortoverrides it like any current level./agent offrestores the pre-profile value, discarding an/effortissued while the profile was active — the same symmetryroute_before_agentalready has with a mid-profile/model.effort_before_agent.is_none(), not the agent layer, so an A-without-key → B-with-key hop captures at B, and A-with → B-with keeps the pre-agent capture.Nonemeans leave alone. A profile omittingreasoningneither applies nor captures; omittingtemperaturefalls through to CLI/config./effort's, no capture, no override change, and the switch still proceeds.docs/agents.mdis updated to say the main loop applies both and that the subagent exclusion stands.Docs
The key table entries for
reasoningandtemperatureare rewritten —reasoningpreviously advertised onlylow/medium/high, where the parser takes all seven/effortlevels — and the subagent-path sentence now states what the main loop does.Tests
9 new, inline in
switch.rs: applied-and-captured; profile beats a live override at activation; restore returns the pre-profile value; restore when there was none before; restore discards a mid-profile change; profile hop keeps the pre-agent capture; restore without a capture is a no-op; invalid value changes nothing; all seven levels parse.Full suite 5432 passed, 0 failed, 1 ignored (baseline 5423 + these 9).
clippy --all-targets -- -D warningsclean,cargo fmt --checkclean.Verified end to end
Driven in a real TUI with
RUST_LOG=dirge::wire=info DIRGE_DUMP_REQUESTS=1and a probe profile (model: low,reasoning: off):Disclosures
--no-default-features --features no-plugin— thepluginfeature needs a janet toolchain unavailable on this host (Build fails on Linux #712). CI covers it.docs/agents.mdkey table omitssubagent_allowandsubagent_timeout_secs, both parsed inagent_defs.rs; and/effortwith no args labels a profile-applied level "(session override)", which is now mildly misleading since a profile writes that same field.