Add instruction parts support#1500
Conversation
🦋 Changeset detectedLatest commit: 77af8b5 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 |
There was a problem hiding this comment.
🟡 Reference equality (===) on Instructions objects prevents realtime session reuse
At agents/src/voice/agent_activity.ts:603, this.agent.instructions === newActivity.agent.instructions uses strict equality (===). Previously instructions was always a string, so === performed value comparison (e.g., "hello" === "hello" is true). Now that instructions can be an Instructions class instance, === performs reference equality for objects — two separate Instructions instances with identical content will compare as false. This causes reusable to be false when midSessionInstructionsUpdate is not supported, forcing an unnecessary realtime session teardown and recreation during agent transitions, even when the instructions haven't actually changed.
(Refers to line 603)
Prompt for agents
In agents/src/voice/agent_activity.ts at line 603, the comparison `this.agent.instructions === newActivity.agent.instructions` uses reference equality for Instructions objects, which breaks value-based comparison that previously worked for strings. The fix should compare Instructions objects by their string representation (e.g. using `.toString()`) when they are not the same reference. One approach is to replace the `===` with a helper that does `a === b || (a.toString() === b.toString())`, or add an `equals()` method to the Instructions class and use it here. The comparison needs to preserve the existing string-vs-string value equality behavior while also handling Instructions-vs-Instructions and mixed cases correctly.
Was this helpful? React with 👍 or 👎 to provide feedback.
a831a0d to
77af8b5
Compare
Summary
Instructionscontent and preserve it through chat context/provider formatting.InstructionPartsfor modular workflow prompt customization.Verification
pnpm build:agentspnpm build:pluginspnpm format:checkpnpm lint(passes with existing warnings)Notes
pnpm api:checkcurrently fails on existing repo configuration issues (api-extractor.jsonmissing in some plugin packages; agents API Extractor rejects existingexport * assyntax).