Repository navigation
feat: add noReply parameter for silent message insertion - #3433
Merged
rekram1-node merged 2 commits intoOct 25, 2025
Merged
Conversation
Add optional noReply parameter to POST /session/{id}/message endpoint that allows
plugins and clients to insert user messages into sessions without triggering AI
inference. When noReply: true, the endpoint creates and persists a UserMessage,
publishes events, and returns immediately without calling streamText() or creating
an AssistantMessage.
This enables the Anthropic Agent Skills pattern where context is injected as user
messages that persist in session history without generating unnecessary AI responses
or consuming API tokens.
Changes:
- Add noReply: z.boolean().optional() to PromptInput schema
- Add early return logic in SessionPrompt.prompt() when noReply is true
- Regenerate SDK with noReply parameter in TypeScript types
- Add comprehensive test suite (8 tests, all passing)
- Update API and SDK documentation with examples
Performance:
- noReply: true completes in ~5ms (vs 8-11s for inference)
- Zero token consumption for context injection
- Fully backward compatible (optional parameter, defaults to false)
Contributor
Author
|
Closes #3378 |
Collaborator
|
/oc delete the file |
Contributor
|
Done. The file |
Co-authored-by: rekram1-node <[email protected]>
|
This is so useful! I can use it in my workflow to remind the agent about current mode and context after compact happens. |
Contributor
Author
|
What was happening before that message? Remember this does not interrupt the agent work, it just injects your message in the context, so if the agent was already compacting for example this will inject your message but will not stop or request a new inference. Compaction already requests new inference. If this is an entirely new session then will have to investigate |
|
@malhashemi My bad, I did not update the opencode, it works great, thanks for the work! |
1 task done
Closed
github-actions Bot
pushed a commit
to yuguorui/opencode
that referenced
this pull request
Jan 18, 2026
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
Rwanbt
pushed a commit
to Rwanbt/unifia
that referenced
this pull request
May 5, 2026
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
AIALRA-0
pushed a commit
to AIALRA-0/opencode-turn-engine
that referenced
this pull request
Jun 10, 2026
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
Rwanbt
pushed a commit
to Rwanbt/unifia
that referenced
this pull request
Jun 14, 2026
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
meSingh
pushed a commit
to meSingh/opencode
that referenced
this pull request
Sep 6, 2026
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


PR Description: Silent Message Insertion (noReply Parameter)
Problem Statement
What pain point in the dev workflow does this address?
Plugin developers cannot inject context into sessions without triggering unnecessary AI inference and consuming API tokens. The current
POST /session/{id}/messageendpoint always triggers AI inference when creating a user message, making it impossible to replicate Anthropic's Agent Skills pattern where context is injected as user messages that persist in session history without generating AI responses.What was the previous state?
Why is this change needed now?
Technical Changes
High-level approach:
Minimal "surgical insertion" - add a single optional boolean parameter (
noReply) to the existing prompt schema and implement early return logic to bypass AI inference when set totrue. The implementation leverages existing type compatibility (UserMessages already satisfyMessageV2.WithParts), requiring only 6 lines of core code changes.Key components modified/added:
packages/opencode/src/session/prompt.ts
noReply: z.boolean().optional()toPromptInputschema (line 97)noReply: true, returnsuserMsgimmediately, bypassing queue check, model resolution, system prompt, tool resolution, and streamingpackages/opencode/test/session/prompt.test.ts
noReplyscenariosnoReply: false, context injection, persistence, performancepackages/sdk/js/src/gen/types.gen.ts (AUTO-REGENERATED)
noReply?: booleantoSessionPromptDatatypepackages/web/src/content/docs/server.mdx
/session/:id/messageendpoint documentationnoReply: trueskips AI inference and returns UserMessagepackages/web/src/content/docs/sdk.mdx
session.prompt()method documentation with examplenoReply: trueDesign decisions and rationale:
Parameter Name:
noReplymode: "context"(overloaded),skipInference(too technical),contextOnly(less clear)Return Type: Keep
MessageV2.WithPartsinfo.roleto determine actual typeEarly Return Placement
Test Strategy
Alternatives considered:
Separate endpoint (e.g.,
POST /session/:id/context)Different parameter names (see "Design decisions" above)
mode,skipInference,contextOnly,silentnoReplyfor clarity and explicitnessSpecial message type
Dependencies added/updated:
Impact
For Developers
New commands/workflows available:
Changed behavior:
noReplyparameter is optional and defaults tofalseBreaking changes:
For AI Agents
Can agents discover and use the new functionality?
How does this enhance agent capabilities?
Agents and plugins can now:
Verification
Automated Tests
bun test packages/opencode/test/session/prompt.test.ts(8/8 passing)bun run typecheck(zero errors)Manual Testing
Manual testing steps performed:
Created session and sent message with
noReply: trueSent multiple sequential
noReply: truemessagesSent message with
noReply: falseafter context injectionRelated PRs/Issues:
Backward compatibility notes:
Fully backward compatible:
noReplyparameter is optional (defaults tofalse)MessageV2.WithPartsunion)Changelog Entry
Type: feat
Summary (1-2 lines):
Add optional
noReplyparameter to POST /session/{id}/message endpoint for context injection without AI inference, enabling the Anthropic Agent Skills pattern with zero token consumption and 1000x performance improvement.Full entry:
Screenshots/Demos
Terminal Output - Test Results
Performance Comparison
Example Usage - TypeScript SDK
Additional Notes
Performance considerations:
noReply: truecompletes in ~5ms (vs 8-11 seconds for inference)Security considerations: