Emit agent config updates in OTLP session logs#1434
Conversation
🦋 Changeset detectedLatest commit: 2d3c28a The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| const configUpdate = new AgentConfigUpdate({ | ||
| toolsAdded: toolsAdded.length > 0 ? toolsAdded : undefined, | ||
| toolsRemoved: toolsRemoved.length > 0 ? toolsRemoved : undefined, | ||
| }); | ||
| this.agent._chatCtx.insert(configUpdate); | ||
| this.agentSession.history.insert(configUpdate); |
There was a problem hiding this comment.
🟡 Same AgentConfigUpdate object inserted into two ChatContexts causes shared mutable state
In updateTools (agent_activity.ts:752-757) and _startSession (agent_activity.ts:469-474), the exact same AgentConfigUpdate object reference is inserted into both this.agent._chatCtx and this.agentSession.history. Since ChatContext stores items by reference, any mutation to the item (e.g., if createdAt were reassigned) would silently affect both contexts. While AgentConfigUpdate fields aren't currently mutated after construction, this violates the pattern seen elsewhere (e.g., AgentHandoffItem in agent_session.ts is typically created separately for each context). This is a latent correctness issue rather than an immediate crash.
Was this helpful? React with 👍 or 👎 to provide feedback.
No description provided.