Repository navigation
fix: hand a message back as a pointer, not the body again #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,11 @@ const PROGRAM_TOOL = 'run_code' | |
|
|
||
| const RETRY_TEXT = 'Your last reply wrote a tool call as plain text (<tool_call>…), so it did not run and nothing happened. Call the tool through the tool interface now, then reply as you meant to.' | ||
|
|
||
| // What a hand-back carries in place of the body. The Bot already read that message in | ||
| // this Session, so sending it again makes the model read one message twice; the pointer | ||
| // is enough to say the work is over and this one is now due an answer. | ||
| export const HANDED_BACK = 'You read its text during that task; it is above in this session. Answer it now.' | ||
|
|
||
| export function install(rt) { | ||
| const { ctx, state } = rt | ||
|
|
||
|
|
@@ -565,13 +570,14 @@ export function install(rt) { | |
| void rt.deliver({ | ||
| fromId: result.info.senderSessionId, | ||
| toId: rt.selfOf(id), | ||
| text: result.text, | ||
| text: HANDED_BACK, | ||
| role: result.info.role, | ||
| exchangeId: result.info.exchangeId, | ||
| replyTo: result.info.replyTo, | ||
| work: result.info.work, | ||
| ...(result.info.roomId ? { roomId: result.info.roomId } : {}), | ||
| deferred: true, | ||
| handedBack: true, | ||
| }).catch(error => rt.warn('ds-bot: handing back a result failed: %s', error)) | ||
| } | ||
| const reason = event.data?.reason | ||
|
|
@@ -657,12 +663,13 @@ export function install(rt) { | |
| fromId: request.info.senderSessionId, | ||
| toId: rt.selfOf(id), | ||
| sessionId: id, | ||
| text: request.text, | ||
| text: HANDED_BACK, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Retain the request body when joined work crosses a part switch. |
||
| role: request.info.role, | ||
| exchangeId: request.info.exchangeId, | ||
| ...(request.info.role === 'room' ? { roomId: request.info.roomId, askedBy: request.info.askedBy, note: 'you read this call during your last task; answer it now' } : {}), | ||
| ...(request.info.senderRoomId ? { fromRoomId: request.info.senderRoomId } : {}), | ||
| deferred: true, | ||
| handedBack: true, | ||
| }).catch(error => rt.warn('ds-bot: deferred request delivery failed: %s', error)) | ||
| } | ||
| break | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a joined request crosses a Session switch, the destination Session is not guaranteed to contain its body:
parts.jsclips handoff history, and itsjob.barerecovery explicitly carries no previous messages (parts.js:894). In that recovery path, the full request enters the new Session only throughhandoffSource().joinedmetadata, whichclaimTrigger()restores for routing but never adds to model-visible content. Replacingrequest.texthere therefore removes the delivery that previously supplied the pending instructions, leaving the answering turn with a false claim that they are above in this Session. Keep the stored body, or supply a concrete old-part lookup anchor, when the original delivery is absent from the destination context.AGENTS.md reference: AGENTS.md:L14-L14
Useful? React with 👍 / 👎.