fix(agent): apply config reload eagerly #100
No reviewers
Labels
No labels
bug
commercial
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jasoncouture/llama-shears!100
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/agent-config-reload-eager"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When idle, the agent's iteration loop doesn't run — so the previous "apply pending config at top of iteration" mechanism left stale config in the data scope indefinitely. Heartbeat read the old
HeartbeatPeriod, so changes to the agent JSON didn't take effect until the user sent a message.Apply the new config directly in
HandleAsync(ConfigurationChangedNotification). The event resumes on the agent's execution context so_dataScopeis the right one, andDataContextScope's backingConcurrentDictionarymakes the write safe alongside concurrent reads.Test plan
HeartbeatPeriodwhile idle; heartbeat fires at the new interval without sending a messagedotnet build+dotnet testcleanPull request overview
This PR aims to make agent config reload take effect even while the agent is idle by applying updated configuration immediately when a
ConfigurationChangedNotificationis received (rather than waiting until the next iteration/turn).Changes:
_pendingConfigstaging mechanism and the per-iterationApplyPendingConfig()call.AgentConfigdirectly to the agent’s_dataScopeinsideHandleAsync(ConfigurationChangedNotification).💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -166,7 +165,8 @@ public sealed partial class Agent :{Applying the updated config directly into
_dataScopefrom the event handler can be lost (or partially applied) if a turn is currently running.CreateAsyncScopeWithData()opens aIDataContextScope.BeginScope()frame for the duration of a turn, andDataContextScopeonly persistsIPersistentDataContextItemvalues when that frame is popped;AgentConfigis not persistent, so a config update arriving mid-turn would be written into the inner frame and then discarded at the end of the turn, reverting to the old config. This also breaks the stated per-turn consistency ofAgentConfig(one turn should see one config end-to-end). Consider deferring the write until no turn scope is active (e.g., acquire_agentLockbefore callingSetItem, so updates during a turn wait until the turn completes) or otherwise ensure the update targets the outer/root scope.