Skip to content

fix(desktop): make agent definition authoritative for model/provider/prompt#1968

Open
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/agent-config-resolver
Open

fix(desktop): make agent definition authoritative for model/provider/prompt#1968
wpfleger96 wants to merge 1 commit into
mainfrom
duncan/agent-config-resolver

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Introduces a single effective-config resolver that makes agent definitions authoritative for model, provider, and system prompt on linked instances. Stale materialized record bytes are never consulted at spawn, deploy, readiness, hash, or card summary.

Resolution semantics (field-specific):

  • model/provider (linked): definition → global. None = inherit global default. Record value never consulted.
  • model/provider (definition-less): instance → global.
  • system_prompt (linked): strictly from definition; blank = no prompt. No global tier for prompt.
  • system_prompt (definition-less): from the instance.
  • Orphaned (linked record, definition missing): spawn and deploy blocked with actionable user-facing error.

Changes:

  • New effective_config resolver module with ConfigSource metadata (definition, global, instance_legacy)
  • All consumers routed through the single resolver: local spawn, deploy, readiness, spawn hash, card summary
  • apply_persona_snapshot no longer preserves stale record model/provider when definition is blank
  • Backend update_managed_agent blocks model/provider/prompt writes for linked records
  • Frontend omits model/provider/systemPrompt submission for linked instances; system prompt override hidden
  • model_source field added to ManagedAgentSummary so card labels distinguish inherited (Default model (X)) from explicit
  • Spawn hash now digests resolved model/provider (not raw record fields) so global default changes trip the restart badge even for runtimes without model_env_var
  • Orphan spawn/deploy blocked with jargon-free error ("This agent's configuration is missing — it may still be syncing or was deleted on another device")
  • Dead persona_field_with_record_fallback and wrapper persona_snapshot_with_agent_config_fallback deleted; callers use persona_snapshot directly
  • Both old blessing tests replaced; 15+ new resolver/deploy/hash/write-guard tests added

@wpfleger96
wpfleger96 requested a review from a team as a code owner July 16, 2026 16:47

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocking: launch restore bypasses the new orphan guard. start_local_agent_with_preflight rejects a linked record whose definition is missing, but restore_managed_agents_on_launch still collects every local start_on_app_launch record, leaves a missing definition untouched at lines 177-182, and then calls spawn_agent_child in Phase B. That spawn path collapses the orphaned model/provider resolver result to (None, None) and continues, while effective_spawn_prompt can still read the materialized record prompt. An orphan configured to start on launch can therefore run despite the PR contract that orphaned linked instances cannot spawn. Please filter/persist an actionable error before Phase B (or put the guard at the shared spawn boundary) and add a restore-path regression test.

Also, the head is currently 13 commits behind main; please rebase and rerun CI before approval.

…prompt

Linked agent instances now resolve effective model/provider through
definition -> global, never consulting stale materialized record bytes.
This fixes the bug where changing an agent's model back to "Inherit
global default" left the previously explicit model active after restart.

A single pure resolver (effective_config.rs) replaces three divergent
resolution paths (record-first local spawn, persona-first deploy, and
persona_field_with_record_fallback snapshot). Both local spawn and deploy
now agree on the same effective values. The backend rejects
model/provider/prompt writes for definition-linked records, and the
frontend omits them.

Deletes dead persona_field_with_record_fallback and collapses
persona_snapshot_with_agent_config_fallback into direct persona_snapshot
calls. Blocks orphan spawn/deploy with an actionable error, enforced once
at the shared spawn_agent_child boundary so every caller (interactive
start, launch restore, start_managed_agent_process) inherits the refusal.
Adds model_source metadata to ManagedAgentSummary so card labels
distinguish inherited vs explicit. Hashes resolved model/provider in
spawn_config_hash so global default changes trip the restart badge for
linked inherited agents regardless of runtime model_env_var.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96
wpfleger96 force-pushed the duncan/agent-config-resolver branch from d7d14df to 2c3dda7 Compare July 17, 2026 18:12
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.

2 participants