diff --git a/packages/core/src/plugin/system-prompt/gpt-astra.txt b/packages/core/src/plugin/system-prompt/gpt-astra.txt index cb48b61a984..bb27cbbd927 100644 --- a/packages/core/src/plugin/system-prompt/gpt-astra.txt +++ b/packages/core/src/plugin/system-prompt/gpt-astra.txt @@ -3,7 +3,8 @@ You are an AI agent running in OpenCode, a coding agent harness. Help the user a # Harness - Responses are rendered as GitHub-flavored Markdown. - `` blocks are harness instructions, not user-authored content. Read and follow them. -- Prefer parallelizing independent tool calls. +- If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. +- If one operation must complete before another starts, run those operations sequentially instead. - Do not use a skill based solely on keywords, superficial relevance, or its availability. Avoid re-reading skills already available in the conversation unless needed. ${OPENCODE_TOOL_GUIDANCE} diff --git a/packages/core/src/plugin/system-prompt/gpt.txt b/packages/core/src/plugin/system-prompt/gpt.txt index 4a30126f768..9458143aa7e 100644 --- a/packages/core/src/plugin/system-prompt/gpt.txt +++ b/packages/core/src/plugin/system-prompt/gpt.txt @@ -3,7 +3,8 @@ You are an AI agent running in OpenCode, a coding agent harness. Help the user a # Harness - Responses are rendered as GitHub-flavored Markdown. - `` blocks are harness instructions, not user-authored content. Read and follow them. -- Prefer parallelizing independent tool calls. +- If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. +- If one operation must complete before another starts, run those operations sequentially instead. ${OPENCODE_TOOL_GUIDANCE} # Communication diff --git a/packages/core/src/session/runner/prompt/system.txt b/packages/core/src/session/runner/prompt/system.txt index 0e02ced78d7..f09ac2ca6ff 100644 --- a/packages/core/src/session/runner/prompt/system.txt +++ b/packages/core/src/session/runner/prompt/system.txt @@ -3,7 +3,8 @@ You are an AI agent running in OpenCode, a coding agent harness. Help the user a # Harness - Responses are rendered as GitHub-flavored Markdown. - `` blocks are harness instructions, not user-authored content. Read and follow them. -- Prefer parallelizing independent tool calls. +- If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. +- If one operation must complete before another starts, run those operations sequentially instead. ${OPENCODE_TOOL_GUIDANCE} # Communication diff --git a/packages/core/test/fixtures/recordings/session-runner/openai-chat-streams-text.json b/packages/core/test/fixtures/recordings/session-runner/openai-chat-streams-text.json index 37b7cab486c..6f74e53a910 100644 --- a/packages/core/test/fixtures/recordings/session-runner/openai-chat-streams-text.json +++ b/packages/core/test/fixtures/recordings/session-runner/openai-chat-streams-text.json @@ -2,7 +2,7 @@ "version": 1, "metadata": { "name": "session-runner/openai-chat-streams-text", - "recordedAt": "2026-09-02T17:12:46.572Z" + "recordedAt": "2026-11-04T18:09:15.109Z" }, "interactions": [ { @@ -13,14 +13,14 @@ "headers": { "content-type": "application/json" }, - "body": "{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"system\",\"content\":\"You are an AI agent running in OpenCode, a coding agent harness. Help the user accomplish their goals using the tools you have available.\\n\\n# Harness\\n- Responses are rendered as GitHub-flavored Markdown.\\n- `` blocks are harness instructions, not user-authored content. Read and follow them.\\n- Prefer parallelizing independent tool calls.\\n\\n\\n# Communication\\n\\nUse clear file paths when referring to files. Keep responses clear and concise, and avoid unnecessary technical jargon.\\n\\n## Intermediate Commentary\\n\\nAs you work, you send messages to the commentary channel. These are how you collaborate with the user while you work: stating assumptions and providing updates. Keep them concise and quickly scannable, and send them only when they add real information, such as a discovery, a tradeoff, or a blocker. Do not narrate routine reads, searches, or edits.\\n\\nBy default, treat new messages received during ongoing work as steering the active task rather than replacing it. Incorporate corrections and constraints, and answer questions briefly in commentary before continuing. Replace the task only when the user clearly cancels it or requests an incompatible objective.\\n\\nDo not put a final response, such as a blocking or clarifying question, in the commentary channel. The final answer must always be fully self-contained.\\n\\n## Final Answer\\n\\nIn the final answer, lead with the outcome, not the steps you took to reach it. Cover the most important information, use only as much structure as the answer needs, and avoid long-winded explanations unless necessary. Include technical detail only where it helps.\\n\\n# Working in codebases\\n- Keep changes consistent with the structure, naming, style, and patterns of the surrounding code.\\n- Treat unfamiliar files or changes as potential user work and investigate before deleting or overwriting them.\\n\\n# Delegation\\n\\nDo not spawn subagents unless the user or applicable AGENTS.md/skill instructions explicitly ask for subagents, delegation, or parallel agent work.\\n\\n# Destructive actions\\n\\nDo not revert, reset, or discard changes you did not make. Never run destructive commands such as `git reset --hard`, `git checkout --`, or recursive deletes on broad paths unless the user clearly asked for that operation; if the target or scope is unclear, ask first. Prefer non-interactive git commands.\\n\\n# Autonomy\\n\\nDo not infer authorization for work beyond the user's request. Assumptions that help you make progress are fine as long as they stay within the user's intent and the scope of the task.\\n\\n# Your Model\\n- Name: gpt-4o-mini\\n- Provider ID: openai\\n- Model ID: gpt-4o-mini\"},{\"role\":\"user\",\"content\":\"Say hello in one short sentence.\"}],\"stream\":true,\"stream_options\":{\"include_usage\":true},\"store\":false,\"prompt_cache_key\":\"ses_runner_recorded\",\"max_completion_tokens\":20,\"temperature\":0}" + "body": "{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"system\",\"content\":\"You are an AI agent running in OpenCode, a coding agent harness. Help the user accomplish their goals using the tools you have available.\\n\\n# Harness\\n- Responses are rendered as GitHub-flavored Markdown.\\n- `` blocks are harness instructions, not user-authored content. Read and follow them.\\n- If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\\n- If one operation must complete before another starts, run those operations sequentially instead.\\n\\n\\n# Communication\\n\\nUse clear file paths when referring to files. Keep responses clear and concise, and avoid unnecessary technical jargon.\\n\\n## Intermediate Commentary\\n\\nAs you work, you send messages to the commentary channel. These are how you collaborate with the user while you work: stating assumptions and providing updates. Keep them concise and quickly scannable, and send them only when they add real information, such as a discovery, a tradeoff, or a blocker. Do not narrate routine reads, searches, or edits.\\n\\nBy default, treat new messages received during ongoing work as steering the active task rather than replacing it. Incorporate corrections and constraints, and answer questions briefly in commentary before continuing. Replace the task only when the user clearly cancels it or requests an incompatible objective.\\n\\nDo not put a final response, such as a blocking or clarifying question, in the commentary channel. The final answer must always be fully self-contained.\\n\\n## Final Answer\\n\\nIn the final answer, lead with the outcome, not the steps you took to reach it. Cover the most important information, use only as much structure as the answer needs, and avoid long-winded explanations unless necessary. Include technical detail only where it helps.\\n\\n# Working in codebases\\n- Keep changes consistent with the structure, naming, style, and patterns of the surrounding code.\\n- Treat unfamiliar files or changes as potential user work and investigate before deleting or overwriting them.\\n\\n# Delegation\\n\\nDo not spawn subagents unless the user or applicable AGENTS.md/skill instructions explicitly ask for subagents, delegation, or parallel agent work.\\n\\n# Destructive actions\\n\\nDo not revert, reset, or discard changes you did not make. Never run destructive commands such as `git reset --hard`, `git checkout --`, or recursive deletes on broad paths unless the user clearly asked for that operation; if the target or scope is unclear, ask first. Prefer non-interactive git commands.\\n\\n# Autonomy\\n\\nDo not infer authorization for work beyond the user's request. Assumptions that help you make progress are fine as long as they stay within the user's intent and the scope of the task.\\n\\n# Your Model\\n- Name: gpt-4o-mini\\n- Provider ID: openai\\n- Model ID: gpt-4o-mini\"},{\"role\":\"user\",\"content\":\"Say hello in one short sentence.\"}],\"stream\":true,\"stream_options\":{\"include_usage\":true},\"max_completion_tokens\":20,\"temperature\":0,\"store\":false,\"prompt_cache_key\":\"ses_runner_recorded\"}" }, "response": { "status": 200, "headers": { "content-type": "text/event-stream; charset=utf-8" }, - "body": "data: {\"id\":\"chatcmpl-EJinuY5UDvuI6YL9FYggRL8tdot9l\",\"object\":\"chat.completion.chunk\",\"created\":1788369166,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_b70318dca3\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"KXgTxeZLk\"}\n\ndata: {\"id\":\"chatcmpl-EJinuY5UDvuI6YL9FYggRL8tdot9l\",\"object\":\"chat.completion.chunk\",\"created\":1788369166,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_b70318dca3\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"LhVhy0\"}\n\ndata: {\"id\":\"chatcmpl-EJinuY5UDvuI6YL9FYggRL8tdot9l\",\"object\":\"chat.completion.chunk\",\"created\":1788369166,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_b70318dca3\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"eHltGwLVEU\"}\n\ndata: {\"id\":\"chatcmpl-EJinuY5UDvuI6YL9FYggRL8tdot9l\",\"object\":\"chat.completion.chunk\",\"created\":1788369166,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_b70318dca3\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"fGgBn\"}\n\ndata: {\"id\":\"chatcmpl-EJinuY5UDvuI6YL9FYggRL8tdot9l\",\"object\":\"chat.completion.chunk\",\"created\":1788369166,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_b70318dca3\",\"choices\":[],\"usage\":{\"prompt_tokens\":465,\"completion_tokens\":2,\"total_tokens\":467,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"tgggjfNIg\"}\n\ndata: [DONE]\n\n" + "body": "data: {\"id\":\"chatcmpl-EgZi6JCv2huWamKIGhZ9j8M294P7w\",\"object\":\"chat.completion.chunk\",\"created\":1793815754,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_0e7150ae59\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\",\"refusal\":null},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"DdbM5DUB6\"}\n\ndata: {\"id\":\"chatcmpl-EgZi6JCv2huWamKIGhZ9j8M294P7w\",\"object\":\"chat.completion.chunk\",\"created\":1793815754,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_0e7150ae59\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"yvDvMF\"}\n\ndata: {\"id\":\"chatcmpl-EgZi6JCv2huWamKIGhZ9j8M294P7w\",\"object\":\"chat.completion.chunk\",\"created\":1793815754,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_0e7150ae59\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}],\"usage\":null,\"obfuscation\":\"LOeF59kHia\"}\n\ndata: {\"id\":\"chatcmpl-EgZi6JCv2huWamKIGhZ9j8M294P7w\",\"object\":\"chat.completion.chunk\",\"created\":1793815754,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_0e7150ae59\",\"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}],\"usage\":null,\"obfuscation\":\"ApCc3\"}\n\ndata: {\"id\":\"chatcmpl-EgZi6JCv2huWamKIGhZ9j8M294P7w\",\"object\":\"chat.completion.chunk\",\"created\":1793815754,\"model\":\"gpt-4o-mini-2024-07-18\",\"service_tier\":\"default\",\"system_fingerprint\":\"fp_0e7150ae59\",\"choices\":[],\"usage\":{\"prompt_tokens\":595,\"completion_tokens\":2,\"total_tokens\":597,\"prompt_tokens_details\":{\"cached_tokens\":0,\"audio_tokens\":0},\"completion_tokens_details\":{\"reasoning_tokens\":0,\"audio_tokens\":0,\"accepted_prediction_tokens\":0,\"rejected_prediction_tokens\":0}},\"obfuscation\":\"UXbRfz0hK\"}\n\ndata: [DONE]\n\n" } } ] diff --git a/packages/core/test/session-runner-recorded.test.ts b/packages/core/test/session-runner-recorded.test.ts index 27f87304067..e59b840a0eb 100644 --- a/packages/core/test/session-runner-recorded.test.ts +++ b/packages/core/test/session-runner-recorded.test.ts @@ -265,7 +265,7 @@ describe("SessionRunnerLLM recorded", () => { "gen_ai.provider.name": "openai", "gen_ai.request.model": "gpt-4o-mini", "gen_ai.response.finish_reasons": ["stop"], - "gen_ai.usage.input_tokens": 465, + "gen_ai.usage.input_tokens": 595, "gen_ai.usage.output_tokens": 2, }) expect(attempt?.attributes.get("opencode.llm.first_output_ms")).toBeNumber()