Jinja exception with gpt-oss model #7715

Open
opened 2026-02-16 18:07:59 -05:00 by yindo · 12 comments
Owner

Originally created by @zaidka on GitHub (Jan 27, 2026).

Originally assigned to: @rekram1-node on GitHub.

Question

When I have opencode using gpt-oss-120b model (locally hosted on llama.cpp), I occasionally get the following error:

While executing CallExpression at line 296, column 36 in source:
...g %}↵                {{- raise_exception("Cannot pass both content and thinking ...
                                           ^
Error: Jinja Exception: Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.

Not sure where to begin troubleshooting this to determine if it's an issue in opencode, llama.cpp, or the jinja template. Please help.

Originally created by @zaidka on GitHub (Jan 27, 2026). Originally assigned to: @rekram1-node on GitHub. ### Question When I have opencode using gpt-oss-120b model (locally hosted on llama.cpp), I occasionally get the following error: ``` While executing CallExpression at line 296, column 36 in source: ...g %}↵ {{- raise_exception("Cannot pass both content and thinking ... ^ Error: Jinja Exception: Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both. ``` Not sure where to begin troubleshooting this to determine if it's an issue in opencode, llama.cpp, or the jinja template. Please help.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 27, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7185: When use gpt-oss-120B by vLLM locally, opencode doesn't call the tools

Both issues involve gpt-oss-120B model with thinking content and tool calling problems. Issue #7185 has 18 comments and may contain relevant troubleshooting steps.

Feel free to ignore if your specific case differs.

@github-actions[bot] commented on GitHub (Jan 27, 2026): This issue might be a duplicate of existing issues. Please check: - #7185: When use gpt-oss-120B by vLLM locally, opencode doesn't call the tools Both issues involve gpt-oss-120B model with thinking content and tool calling problems. Issue #7185 has 18 comments and may contain relevant troubleshooting steps. Feel free to ignore if your specific case differs.
Author
Owner

@z64 commented on GitHub (Feb 2, 2026):

I also started encountering this recently, also running gpt-oss-120b locally. I don't believe I've updated my LLM toolchain stuff, it seems to have broken after one of the more recent opencode updates.

@z64 commented on GitHub (Feb 2, 2026): I also started encountering this recently, also running gpt-oss-120b locally. I don't believe I've updated my LLM toolchain stuff, it seems to have broken after one of the more recent opencode updates.
Author
Owner

@tarcon commented on GitHub (Feb 2, 2026):

Same for me on llama.cpp
A custom grammar allows tool calls to work generally, but in longer running sessions it still fails unrecoverably.

I have seen that the unsloth model variants have fixed tool calling. Might be worth to test.

@tarcon commented on GitHub (Feb 2, 2026): Same for me on llama.cpp A [custom grammar](https://github.com/ggml-org/llama.cpp/discussions/15396#discussioncomment-14145537) allows tool calls to work generally, but in longer running sessions it still fails unrecoverably. I have seen that the unsloth model variants have fixed tool calling. Might be worth to test.
Author
Owner

@zaidka commented on GitHub (Feb 2, 2026):

I have seen that the unsloth model variants have fixed tool calling. Might be worth to test.

I am actually using the unsloth model. In my case it only seems to fail in longer contexts. Usually at around 60-80k tokens is where I encounter this error.

@zaidka commented on GitHub (Feb 2, 2026): > I have seen that the unsloth model variants have fixed tool calling. Might be worth to test. I am actually using the unsloth model. In my case it only seems to fail in longer contexts. Usually at around 60-80k tokens is where I encounter this error.
Author
Owner

@z64 commented on GitHub (Feb 2, 2026):

Using ggml distribution here.

@z64 commented on GitHub (Feb 2, 2026): Using ggml distribution here.
Author
Owner

@namirsab commented on GitHub (Feb 3, 2026):

Same happens to me, also using llama.cpp and ggml-org/gpt-oss-120b-GGUF

@namirsab commented on GitHub (Feb 3, 2026): Same happens to me, also using llama.cpp and ggml-org/gpt-oss-120b-GGUF
Author
Owner

@erikvanzijst commented on GitHub (Feb 4, 2026):

Just chiming in to share I'm having the same issue and have been failing to get either the ggml-org, or unsloth version to work with llama.cpp and opencode. The specific failures differ a little between models, settings and templates, but ultimately all seem to come down to gpt-oss outputing Harmony and opencode not implementing that?

Has anyone gotten gpt-oss-120b to work reliably from opencode?

The sweet spot for my local hardware is a strong agentic coding model that fits in 64-96GB and gpt-oss-120b seems to be among the best in that category.

@erikvanzijst commented on GitHub (Feb 4, 2026): Just chiming in to share I'm having the same issue and have been failing to get either the ggml-org, or unsloth version to work with llama.cpp and opencode. The specific failures differ a little between models, settings and templates, but ultimately all seem to come down to gpt-oss outputing Harmony and opencode not implementing that? Has anyone gotten gpt-oss-120b to work reliably from opencode? The sweet spot for my local hardware is a strong agentic coding model that fits in 64-96GB and gpt-oss-120b seems to be among the best in that category.
Author
Owner

@thejacer commented on GitHub (Feb 7, 2026):

Also having this issue. It only happens with GPT-OSS-120b. I've tried the Unsloth ggufs as well.

@thejacer commented on GitHub (Feb 7, 2026): Also having this issue. It only happens with GPT-OSS-120b. I've tried the Unsloth ggufs as well.
Author
Owner

@imraf commented on GitHub (Feb 8, 2026):

I've just encountered this as well.

Using gpt-oss:120b with llama.cpp, I am getting this error:

Error: Jinja Exception: Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.","type":"server_error"}}

So this is Jinja throwing an error as Opencode presumably created a bad message.

@imraf commented on GitHub (Feb 8, 2026): I've just encountered this as well. Using gpt-oss:120b with llama.cpp, I am getting this error: `Error: Jinja Exception: Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.","type":"server_error"}} ` So this is Jinja throwing an error as Opencode presumably created a bad message.
Author
Owner

@Inndy commented on GitHub (Feb 10, 2026):

OpenCode sends malformed assistant messages to the GPT-OSS template

The error happens because OpenCode constructs assistant message history with all three fields populated simultaneously:

{
    "role": "assistant",
    "content": "I will fetch a search result...",
    "reasoning_content": "The user asks about...",
    "tool_calls": [{"function": {"name": "webfetch", ...}}]
}

The GPT-OSS template has an explicit validation at openai-gpt-oss-120b.jinja#L289:

{%- if "tool_calls" in message %}

...

  {%- if message.content and message.thinking %}
    {{- raise_exception("Cannot pass both content and thinking...") }}

Here is the request header and formatted JSON body

POST /chat/completions HTTP/1.1
content-type: application/json
user-agent: opencode/1.1.53 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5
Connection: keep-alive
Accept: */*
Host: host.docker.internal:12345
Accept-Encoding: gzip, deflate, br, zstd
Content-Length: 52561
{
	"model": "gpt-oss-120b",
	"max_tokens": 32000,
	"messages": [
		{
			"role": "system",
			"content": "You are opencode, an agent - please keep going until the user...s query is completely resolved, before ending your turn and yielding back to the user.\n\nYour thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.\n\nYou MUST iterate and keep going until the problem is solved.\n\nYou have everything you need to resolve this problem. I want you to fully solve this autonomously before coming back to me.\n\nOnly terminate your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly and completely solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn.\n\nTHE PROBLEM CAN NOT BE SOLVED WITHOUT EXTENSIVE INTERNET RESEARCH.\n\nYou must use the webfetch tool to recursively gather all information from URL's provided to  you by the user, as well as any links you find in the content of those pages.\n\nYour knowledge on everything is out of date because your training date is in the past. \n\nYou CANNOT successfully complete this task without using Google to verify your\nunderstanding of third party packages and dependencies is up to date. You must use the webfetch tool to search google for how to properly use libraries, packages, frameworks, dependencies, etc. every single time you install or implement one. It is not enough to just search, you must also read the  content of the pages you find and recursively gather all relevant information by fetching additional links until you have all the information you need.\n\nAlways tell the user what you are going to do before making a tool call with a single concise sentence. This will help them understand what you are doing and why.\n\nIf the user request is \"resume\" or \"continue\" or \"try again\", check the previous conversation history to see what the next incomplete step in the todo list is. Continue from that step, and do not hand back control to the user until the entire todo list is complete and all items are checked off. Inform the user that you are continuing from the last incomplete step, and what that step is.\n\nTake your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Use the sequential thinking tool if available. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided.\n\nYou MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.\n\nYou MUST keep working until the problem is completely solved, and all items in the todo list are checked off. Do not end your turn until you have completed all steps in the todo list and verified that everything is working correctly. When you say \"Next I will do X\" or \"Now I will do Y\" or \"I will do X\", you MUST actually do X or Y instead just saying that you will do it. \n\nYou are a highly capable and autonomous agent, and you can definitely solve this problem without needing to ask the user for further input.\n\n# Workflow\n1. Fetch any URL's provided by the user using the `webfetch` tool.\n2. Understand the problem deeply. Carefully read the issue and think critically about what is required. Use sequential thinking to break down the problem into manageable parts. Consider the following:\n   - What is the expected behavior?\n   - What are the edge cases?\n   - What are the potential pitfalls?\n   - How does this fit into the larger context of the codebase?\n   - What are the dependencies and interactions with other parts of the code?\n3. Investigate the codebase. Explore relevant files, search for key functions, and gather context.\n4. Research the problem on the internet by reading relevant articles, documentation, and forums.\n5. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. Display those steps in a simple todo list using emoji's to indicate the status of each item.\n6. Implement the fix incrementally. Make small, testable code changes.\n7. Debug as needed. Use debugging techniques to isolate and resolve issues.\n8. Test frequently. Run tests after each change to verify correctness.\n9. Iterate until the root cause is fixed and all tests pass.\n10. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete.\n\nRefer to the detailed sections below for more information on each step.\n\n## 1. Fetch Provided URLs\n- If the user provides a URL, use the `webfetch` tool to retrieve the content of the provided URL.\n- After fetching, review the content returned by the webfetch tool.\n- If you find any additional URLs or links that are relevant, use the `webfetch` tool again to retrieve those links.\n- Recursively gather all relevant information by fetching additional links until you have all the information you need.\n\n## 2. Deeply Understand the Problem\nCarefully read the issue and think hard about a plan to solve it before coding.\n\n## 3. Codebase Investigation\n- Explore relevant files and directories.\n- Search for key functions, classes, or variables related to the issue.\n- Read and understand relevant code snippets.\n- Identify the root cause of the problem.\n- Validate and update your understanding continuously as you gather more context.\n\n## 4. Internet Research\n- Use the `webfetch` tool to search google by fetching the URL `https://www.google.com/search?q=your+search+query`.\n- After fetching, review the content returned by the fetch tool.\n- You MUST fetch the contents of the most relevant links to gather information. Do not rely on the summary that you find in the search results.\n- As you fetch each link, read the content thoroughly and fetch any additional links that you find within the content that are relevant to the problem.\n- Recursively gather all relevant information by fetching links until you have all the information you need.\n\n## 5. Develop a Detailed Plan \n- Outline a specific, simple, and verifiable sequence of steps to fix the problem.\n- Create a todo list in markdown format to track your progress.\n- Each time you complete a step, check it off using `[x]` syntax.\n- Each time you check off a step, display the updated todo list to the user.\n- Make sure that you ACTUALLY continue on to the next step after checkin off a step instead of ending your turn and asking the user what they want to do next.\n\n## 6. Making Code Changes\n- Before editing, always read the relevant file contents or section to ensure complete context.\n- Always read 2000 lines of code at a time to ensure you have enough context.\n- If a patch is not applied correctly, attempt to reapply it.\n- Make small, testable, incremental changes that logically follow from your investigation and plan.\n- Whenever you detect that a project requires an environment variable (such as an API key or secret), always check if a .env file exists in the project root. If it does not exist, automatically create a .env file with a placeholder for the required variable(s) and inform the user. Do this proactively, without waiting for the user to request it.\n\n## 7. Debugging\n- Make code changes only if you have high confidence they can solve the problem\n- When debugging, try to determine the root cause rather than addressing symptoms\n- Debug for as long as needed to identify the root cause and identify a fix\n- Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's happening\n- To test hypotheses, you can also add test statements or functions\n- Revisit your assumptions if unexpected behavior occurs.\n\n\n# Communication Guidelines\nAlways communicate clearly and concisely in a casual, friendly yet professional tone. \n<examples>\n\"Let me fetch the URL you provided to gather more information.\"\n\"Ok, I've got all of the information I need on the LIFX API and I know how to use it.\"\n\"Now, I will search the codebase for the function that handles the LIFX API requests.\"\n\"I need to update several files here - stand by\"\n\"OK! Now let's run the tests to make sure everything is working correctly.\"\n\"Whelp - I see we have some problems. Let's fix those up.\"\n</examples>\n\n- Respond with clear, direct answers. Use bullet points and code blocks for structure. - Avoid unnecessary explanations, repetition, and filler.  \n- Always write code directly to the correct files.\n- Do not display code to the user unless they specifically ask for it.\n- Only elaborate when clarification is essential for accuracy or user understanding.\n\n# Memory\nYou have a memory that stores information about the user and their preferences. This memory is used to provide a more personalized experience. You can access and update this memory as needed. The memory is stored in a file called `.github/instructions/memory.instruction.md`. If the file is empty, you'll need to create it. \n\nWhen creating a new memory file, you MUST include the following front matter at the top of the file:\n```yaml\n---\napplyTo: '**'\n---\n```\n\nIf the user asks you to remember something or add something to your memory, you can do so by updating the memory file.\n\n# Reading Files and Folders\n\n**Always check if you have already read a file, folder, or workspace structure before reading it again.**\n\n- If you have already read the content and it has not changed, do NOT re-read it.\n- Only re-read files or folders if:\n  - You suspect the content has changed since your last read.\n  - You have made edits to the file or folder.\n  - You encounter an error that suggests the context may be stale or incomplete.\n- Use your internal memory and previous context to avoid redundant reads.\n- This will save time, reduce unnecessary operations, and make your workflow more efficient.\n\n# Writing Prompts\nIf you are asked to write a prompt,  you should always generate the prompt in markdown format.\n\nIf you are not writing the prompt in a file, you should always wrap the prompt in triple backticks so that it is formatted correctly and can be easily copied from the chat.\n\nRemember that todo lists must always be written in markdown format and must always be wrapped in triple backticks.\n\n# Git \nIf the user tells you to stage and commit, you may do so. \n\nYou are NEVER allowed to stage and commit files automatically.\n\nYou are powered by the model named gpt-oss-120b. The exact model ID is fmwk/gpt-oss-120b\nHere is some useful information about the environment you are running in:\n<env>\n  Working directory: /code\n  Is directory a git repo: no\n  Platform: linux\n  Today's date: Tue Feb 10 2026\n</env>\n<directories>\n  \n</directories>"
		},
		{
			"role": "user",
			"content": [
				{
					"type": "text",
					"text": "check @opencode we already implement container-per-project.\n\n- how to reuse old conatiner?\n- what if old container is \"dead\"?"
				},
				{
					"type": "text",
					"text": "Called the Read tool with the following input: {\"filePath\":\"/code/opencode\"}"
				},
				{
					"type": "text",
					"text": "<file>\n00001| #!/usr/bin/env bash\n00002| # Determine git root and compute hash\n00003| if git rev-parse --show-toplevel >/dev/null 2>&1; then\n00004|   GIT_ROOT=$(git rev-parse --show-toplevel)\n00005|   HASH=$(echo -n \"$GIT_ROOT\" | sha1sum | cut -c1-8)\n00006|   MOUNT_SRC=\"$GIT_ROOT\"\n00007| else\n00008|   HASH=$(echo -n \"$PWD\" | sha1sum | cut -c1-8)\n00009|   MOUNT_SRC=\"$PWD\"\n00010| fi\n00011| # Run docker container with name based on hash, without --rm\n00012| exec docker run -it --name \"opencode-$HASH\" -v \"$MOUNT_SRC:/code\" --workdir /code opencode-dev:latest /root/.opencode/bin/opencode\n00013| \n\n(End of file - total 13 lines)\n</file>"
				}
			]
		},
		{
			"role": "user",
			"content": [
				{
					"type": "text",
					"text": "check @opencode we already implement container-per-project.\n\n- how to reuse old conatiner?\n- what if old container is \"dead\"?\n- what about spawn dummy container, and exec everytime?"
				},
				{
					"type": "text",
					"text": "Called the Read tool with the following input: {\"filePath\":\"/code/opencode\"}"
				},
				{
					"type": "text",
					"text": "<file>\n00001| #!/usr/bin/env bash\n00002| # Determine git root and compute hash\n00003| if git rev-parse --show-toplevel >/dev/null 2>&1; then\n00004|   GIT_ROOT=$(git rev-parse --show-toplevel)\n00005|   HASH=$(echo -n \"$GIT_ROOT\" | sha1sum | cut -c1-8)\n00006|   MOUNT_SRC=\"$GIT_ROOT\"\n00007| else\n00008|   HASH=$(echo -n \"$PWD\" | sha1sum | cut -c1-8)\n00009|   MOUNT_SRC=\"$PWD\"\n00010| fi\n00011| # Run docker container with name based on hash, without --rm\n00012| exec docker run -it --name \"opencode-$HASH\" -v \"$MOUNT_SRC:/code\" --workdir /code opencode-dev:latest /root/.opencode/bin/opencode\n00013| \n\n(End of file - total 13 lines)\n</file>"
				},
				{
					"type": "text",
					"text": "<system-reminder>\n# Plan Mode - System Reminder\n\nCRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:\nANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,\nor ANY other bash command to manipulate files - commands may ONLY read/inspect.\nThis ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user\nedit requests. You may ONLY observe, analyze, and plan. Any modification attempt\nis a critical violation. ZERO exceptions.\n\n---\n\n## Responsibility\n\nYour current responsibility is to think, read, search, and delegate explore agents to construct a well-formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.\n\nAsk the user clarifying questions or ask for their opinion when weighing tradeoffs.\n\n**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.\n\n---\n\n## Important\n\nThe user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.\n</system-reminder>\n"
				}
			]
		},
		{
			"role": "assistant",
			"content": "I will fetch a search result about reusing existing Docker containers by name and handling dead containers.",
			"reasoning_content": "The user asks about container-per-project implementation in opencode (script). Wants to know: how to reuse old container? what if old container is dead? what about spawning dummy container and exec every time?\n\nWe are in read-only phase, cannot edit. We need to provide explanation and suggestions. Possibly need to research Docker behavior. Use webfetch to search topics: Docker container reuse, exec into existing container, handling stopped containers, dummy container pattern. Provide answer.\n\nWe can fetch web pages for reference.",
			"tool_calls": [
				{
					"id": "jrAbCB7j1RMQpYcp39uHs8Lq7rrazp1V",
					"type": "function",
					"function": {
						"name": "webfetch",
						"arguments": "{\"url\":\"https://www.google.com/search?q=docker+reuse+existing+container+by+name+exec+if+stopped\",\"format\":\"text\",\"timeout\":60}"
					}
				}
			]
		},
		{
			"role": "tool",
			"tool_call_id": "jrAbCB7j1RMQpYcp39uHs8Lq7rrazp1V",
			"content": "Google SearchIf you're having trouble accessing Google Search, please&nbsp;click here, or send&nbsp;feedback."
		}
	],
	"tools": [
		{
			"type": "function",
			"function": {
				"name": "question",
				"description": "Use this tool when you need to ask the user questions during execution. This allows you to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take.\n\nUsage notes:\n- When `custom` is enabled (default), a \"Type your own answer\" option is added automatically; don't include \"Other\" or catch-all options\n- Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one\n- If you recommend a specific option, make that the first option in the list and add \"(Recommended)\" at the end of the label\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"questions": {
							"description": "Questions to ask",
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"question": {
										"description": "Complete question",
										"type": "string"
									},
									"header": {
										"description": "Very short label (max 30 chars)",
										"type": "string"
									},
									"options": {
										"description": "Available choices",
										"type": "array",
										"items": {
											"ref": "QuestionOption",
											"type": "object",
											"properties": {
												"label": {
													"description": "Display text (1-5 words, concise)",
													"type": "string"
												},
												"description": {
													"description": "Explanation of choice",
													"type": "string"
												}
											},
											"required": [
												"label",
												"description"
											],
											"additionalProperties": false
										}
									},
									"multiple": {
										"description": "Allow selecting multiple choices",
										"type": "boolean"
									}
								},
								"required": [
									"question",
									"header",
									"options"
								],
								"additionalProperties": false
							}
						}
					},
					"required": [
						"questions"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "bash",
				"description": "Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.\n\nAll commands run in /code by default. Use the `workdir` parameter if you need to run a command in a different directory. AVOID using `cd <directory> && <command>` patterns - use `workdir` instead.\n\nIMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.\n\nBefore executing the command, please follow these steps:\n\n1. Directory Verification:\n   - If the command will create new directories or files, first use `ls` to verify the parent directory exists and is the correct location\n   - For example, before running \"mkdir foo/bar\", first use `ls foo` to check that \"foo\" exists and is the intended parent directory\n\n2. Command Execution:\n   - Always quote file paths that contain spaces with double quotes (e.g., rm \"path with spaces/file.txt\")\n   - Examples of proper quoting:\n     - mkdir \"/Users/name/My Documents\" (correct)\n     - mkdir /Users/name/My Documents (incorrect - will fail)\n     - python \"/path/with spaces/script.py\" (correct)\n     - python /path/with spaces/script.py (incorrect - will fail)\n   - After ensuring proper quoting, execute the command.\n   - Capture the output of the command.\n\nUsage notes:\n  - The command argument is required.\n  - You can specify an optional timeout in milliseconds. If not specified, commands will time out after 120000ms (2 minutes).\n  - It is very helpful if you write a clear, concise description of what this command does in 5-10 words.\n  - If the output exceeds 2000 lines or 51200 bytes, it will be truncated and the full output will be written to a file. You can use Read with offset/limit to read specific sections or Grep to search the full content. Because of this, you do NOT need to use `head`, `tail`, or other truncation commands to limit output - just run the command directly.\n\n  - Avoid using Bash with the `find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:\n    - File search: Use Glob (NOT find or ls)\n    - Content search: Use Grep (NOT grep or rg)\n    - Read files: Use Read (NOT cat/head/tail)\n    - Edit files: Use Edit (NOT sed/awk)\n    - Write files: Use Write (NOT echo >/cat <<EOF)\n    - Communication: Output text directly (NOT echo/printf)\n  - When issuing multiple commands:\n    - If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. For example, if you need to run \"git status\" and \"git diff\", send a single message with two Bash tool calls in parallel.\n    - If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together (e.g., `git add . && git commit -m \"message\" && git push`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.\n    - Use ';' only when you need to run commands sequentially but don't care if earlier commands fail\n    - DO NOT use newlines to separate commands (newlines are ok in quoted strings)\n  - AVOID using `cd <directory> && <command>`. Use the `workdir` parameter to change directories instead.\n    <good-example>\n    Use workdir=\"/foo/bar\" with command: pytest tests\n    </good-example>\n    <bad-example>\n    cd /foo/bar && pytest tests\n    </bad-example>\n\n# Committing changes with git\n\nOnly create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:\n\nGit Safety Protocol:\n- NEVER update the git config\n- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them\n- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it\n- NEVER run force push to main/master, warn the user if they request it\n- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:\n  (1) User explicitly requested amend, OR commit SUCCEEDED but pre-commit hook auto-modified files that need including\n  (2) HEAD commit was created by you in this conversation (verify: git log -1 --format='%an %ae')\n  (3) Commit has NOT been pushed to remote (verify: git status shows \"Your branch is ahead\")\n- CRITICAL: If commit FAILED or was REJECTED by hook, NEVER amend - fix the issue and create a NEW commit\n- CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push)\n- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the Bash tool:\n  - Run a git status command to see all untracked files.\n  - Run a git diff command to see both staged and unstaged changes that will be committed.\n  - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.\n2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:\n  - Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. \"add\" means a wholly new feature, \"update\" means an enhancement to an existing feature, \"fix\" means a bug fix, etc.).\n  - Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files\n  - Draft a concise (1-2 sentences) commit message that focuses on the \"why\" rather than the \"what\"\n  - Ensure it accurately reflects the changes and their purpose\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:\n   - Add relevant untracked files to the staging area.\n   - Create the commit with a message\n   - Run git status after the commit completes to verify success.\n   Note: git status depends on the commit completing, so run it sequentially after the commit.\n4. If the commit fails due to pre-commit hook, fix the issue and create a NEW commit (see amend rules above)\n\nImportant notes:\n- NEVER run additional commands to read or explore code, besides git bash commands\n- NEVER use the TodoWrite or Task tools\n- DO NOT push to the remote repository unless the user explicitly asks you to do so\n- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.\n- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit\n\n# Creating pull requests\nUse the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.\n\nIMPORTANT: When the user asks you to create a pull request, follow these steps carefully:\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch:\n   - Run a git status command to see all untracked files\n   - Run a git diff command to see both staged and unstaged changes that will be committed\n   - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote\n   - Run a git log command and `git diff [base-branch]...HEAD` to understand the full commit history for the current branch (from the time it diverged from the base branch)\n2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:\n   - Create new branch if needed\n   - Push to remote with -u flag if needed\n   - Create PR using gh pr create with the format below. Use a HEREDOC to pass the body to ensure correct formatting.\n<example>\ngh pr create --title \"the pr title\" --body \"$(cat <<'EOF'\n## Summary\n<1-3 bullet points>\n</example>\n\nImportant:\n- DO NOT use the TodoWrite or Task tools\n- Return the PR URL when you're done, so the user can see it\n\n# Other common operations\n- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments\n",
					"parameters": {
						"$schema": "https://json-schema.org/draft/2020-12/schema",
						"type": "object",
						"properties": {
							"command": {
								"description": "The command to execute",
								"type": "string"
							},
							"timeout": {
								"description": "Optional timeout in milliseconds",
								"type": "number"
							},
							"workdir": {
								"description": "The working directory to run the command in. Defaults to /code. Use this instead of 'cd' commands.",
								"type": "string"
							},
							"description": {
								"description": "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'",
								"type": "string"
							}
						},
						"required": [
							"command",
							"description"
						],
						"additionalProperties": false
					}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "read",
				"description": "Reads a file from the local filesystem. You can access any file directly by using this tool.\nAssume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\n\nUsage:\n- The filePath parameter must be an absolute path, not a relative path\n- By default, it reads up to 2000 lines starting from the beginning of the file\n- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\n- Any lines longer than 2000 characters will be truncated\n- Results are returned using cat -n format, with line numbers starting at 1\n- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.\n- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.\n- You can read image files using this tool.\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"filePath": {
							"description": "The path to the file to read",
							"type": "string"
						},
						"offset": {
							"description": "The line number to start reading from (0-based)",
							"type": "number"
						},
						"limit": {
							"description": "The number of lines to read (defaults to 2000)",
							"type": "number"
						}
					},
					"required": [
						"filePath"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "glob",
				"description": "- Fast file pattern matching tool that works with any codebase size\n- Supports glob patterns like \"**/*.js\" or \"src/**/*.ts\"\n- Returns matching file paths sorted by modification time\n- Use this tool when you need to find files by name patterns\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n- You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"pattern": {
							"description": "The glob pattern to match files against",
							"type": "string"
						},
						"path": {
							"description": "The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter \"undefined\" or \"null\" - simply omit it for the default behavior. Must be a valid directory path if provided.",
							"type": "string"
						}
					},
					"required": [
						"pattern"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "grep",
				"description": "- Fast content search tool that works with any codebase size\n- Searches file contents using regular expressions\n- Supports full regex syntax (eg. \"log.*Error\", \"function\\s+\\w+\", etc.)\n- Filter files by pattern with the include parameter (eg. \"*.js\", \"*.{ts,tsx}\")\n- Returns file paths and line numbers with at least one match sorted by modification time\n- Use this tool when you need to find files containing specific patterns\n- If you need to identify/count the number of matches within files, use the Bash tool with `rg` (ripgrep) directly. Do NOT use `grep`.\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"pattern": {
							"description": "The regex pattern to search for in file contents",
							"type": "string"
						},
						"path": {
							"description": "The directory to search in. Defaults to the current working directory.",
							"type": "string"
						},
						"include": {
							"description": "File pattern to include in the search (e.g. \"*.js\", \"*.{ts,tsx}\")",
							"type": "string"
						}
					},
					"required": [
						"pattern"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "edit",
				"description": "Performs exact string replacements in files. \n\nUsage:\n- You must use your `Read` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the oldString or newString.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if `oldString` is not found in the file with an error \"oldString not found in content\".\n- The edit will FAIL if `oldString` is found multiple times in the file with an error \"oldString found multiple times and requires more code context to uniquely identify the intended match\". Either provide a larger string with more surrounding context to make it unique or use `replaceAll` to change every instance of `oldString`. \n- Use `replaceAll` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"filePath": {
							"description": "The absolute path to the file to modify",
							"type": "string"
						},
						"oldString": {
							"description": "The text to replace",
							"type": "string"
						},
						"newString": {
							"description": "The text to replace it with (must be different from oldString)",
							"type": "string"
						},
						"replaceAll": {
							"description": "Replace all occurrences of oldString (default false)",
							"type": "boolean"
						}
					},
					"required": [
						"filePath",
						"oldString",
						"newString"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "write",
				"description": "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"content": {
							"description": "The content to write to the file",
							"type": "string"
						},
						"filePath": {
							"description": "The absolute path to the file to write (must be absolute, not relative)",
							"type": "string"
						}
					},
					"required": [
						"content",
						"filePath"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "task",
				"description": "Launch a new agent to handle complex, multistep tasks autonomously.\n\nAvailable agent types and the tools they have access to:\n- general: General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel.\n- explore: Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.\n\nWhen using the Task tool, you must specify a subagent_type parameter to select which agent type to use.\n\nWhen to use the Task tool:\n- When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description=\"Check the file\", prompt=\"/check-file path/to/file.py\")\n\nWhen NOT to use the Task tool:\n- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly\n- If you are searching for a specific class definition like \"class Foo\", use the Glob tool instead, to find the match more quickly\n- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly\n- Other tasks that are not related to the agent descriptions above\n\n\nUsage notes:\n1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\n2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.\n3. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.\n4. The agent's outputs should generally be trusted\n5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).\n6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.\n\nExample usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):\n\n<example_agent_descriptions>\n\"code-reviewer\": use this agent after you are done writing a significant piece of code\n\"greeting-responder\": use this agent when to respond to user greetings with a friendly joke\n</example_agent_description>\n\n<example>\nuser: \"Please write a function that checks if a number is prime\"\nassistant: Sure let me write a function that checks if a number is prime\nassistant: First let me use the Write tool to write a function that checks if a number is prime\nassistant: I'm going to use the Write tool to write the following code:\n<code>\nfunction isPrime(n) {\n  if (n <= 1) return false\n  for (let i = 2; i * i <= n; i++) {\n    if (n % i === 0) return false\n  }\n  return true\n}\n</code>\n<commentary>\nSince a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code\n</commentary>\nassistant: Now let me use the code-reviewer agent to review the code\nassistant: Uses the Task tool to launch the code-reviewer agent\n</example>\n\n<example>\nuser: \"Hello\"\n<commentary>\nSince the user is greeting, use the greeting-responder agent to respond with a friendly joke\n</commentary>\nassistant: \"I'm going to use the Task tool to launch the with the greeting-responder agent\"\n</example>\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"description": {
							"description": "A short (3-5 words) description of the task",
							"type": "string"
						},
						"prompt": {
							"description": "The task for the agent to perform",
							"type": "string"
						},
						"subagent_type": {
							"description": "The type of specialized agent to use for this task",
							"type": "string"
						},
						"task_id": {
							"description": "This should only be set if you mean to resume a previous task (you can pass a prior task_id and the task will continue the same subagent session as before instead of creating a fresh one)",
							"type": "string"
						},
						"command": {
							"description": "The command that triggered this task",
							"type": "string"
						}
					},
					"required": [
						"description",
						"prompt",
						"subagent_type"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "webfetch",
				"description": "- Fetches content from a specified URL\n- Takes a URL and optional format as input\n- Fetches the URL content, converts to requested format (markdown by default)\n- Returns the content in the specified format\n- Use this tool when you need to retrieve and analyze web content\n\nUsage notes:\n  - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.\n  - The URL must be a fully-formed valid URL\n  - HTTP URLs will be automatically upgraded to HTTPS\n  - Format options: \"markdown\" (default), \"text\", or \"html\"\n  - This tool is read-only and does not modify any files\n  - Results may be summarized if the content is very large\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"url": {
							"description": "The URL to fetch content from",
							"type": "string"
						},
						"format": {
							"description": "The format to return the content in (text, markdown, or html). Defaults to markdown.",
							"default": "markdown",
							"type": "string",
							"enum": [
								"text",
								"markdown",
								"html"
							]
						},
						"timeout": {
							"description": "Optional timeout in seconds (max 120)",
							"type": "number"
						}
					},
					"required": [
						"url",
						"format"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "todowrite",
				"description": "Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.\nIt also helps the user understand the progress of the task and overall progress of their requests.\n\n## When to Use This Tool\nUse this tool proactively in these scenarios:\n\n1. Complex multistep tasks - When a task requires 3 or more distinct steps or actions\n2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations\n3. User explicitly requests todo list - When the user directly asks you to use the todo list\n4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)\n5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.\n6. After completing a task - Mark it complete and add any new follow-up tasks\n7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.\n\n## When NOT to Use This Tool\n\nSkip using this tool when:\n1. There is only a single, straightforward task\n2. The task is trivial and tracking it provides no organizational benefit\n3. The task can be completed in less than 3 trivial steps\n4. The task is purely conversational or informational\n\nNOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.\n\n## Examples of When to Use the Todo List\n\n<example>\nUser: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!\nAssistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.\n*Creates todo list with the following items:*\n1. Create dark mode toggle component in Settings page\n2. Add dark mode state management (context/store)\n3. Implement CSS-in-JS styles for dark theme\n4. Update existing components to support theme switching\n5. Run tests and build process, addressing any failures or errors that occur\n*Begins working on the first task*\n\n<reasoning>\nThe assistant used the todo list because:\n1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes\n2. The user explicitly requested tests and build be run afterward\n3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task\n</reasoning>\n</example>\n\n<example>\nUser: Help me rename the function getCwd to getCurrentWorkingDirectory across my project\nAssistant: Let me first search through your codebase to find all occurrences of 'getCwd'.\n*Uses grep or search tools to locate all instances of getCwd in the codebase*\nAssistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.\n*Creates todo list with specific items for each file that needs updating*\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant searched to understand the scope of the task\n2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps\n3. The todo list helps ensure every instance is tracked and updated systematically\n4. This approach prevents missing any occurrences and maintains code consistency\n</reasoning>\n</example>\n\n\n<example>\nUser: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.\nAssistant: I'll help implement these features. First, let's add all the features to the todo list.\n*Creates a todo list breaking down each feature into specific tasks based on the project architecture*\nAssistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.\n\n<reasoning>\nThe assistant used the todo list because:\n1. The user provided multiple complex features to implement in a comma separated list\n2. The todo list helps organize these large features into manageable tasks\n3. This approach allows for tracking progress across the entire implementation\n</reasoning>\n</example>\n\n<example>\nUser: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>\nAssistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.\n*Reviews component structure, render patterns, state management, and data fetching*\nAssistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.\n*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*\nLet's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant examined the codebase to identify specific performance issues\n2. Based on this analysis, it identified multiple optimization opportunities\n3. Performance optimization is a non-trivial task requiring multiple steps\n4. The todo list helps methodically track improvements across different components\n5. This systematic approach ensures all performance bottlenecks are addressed\n</reasoning>\n</example>\n\n## Examples of When NOT to Use the Todo List\n\n<example>\nUser: How do I print 'Hello World' in Python?\nAssistant: In Python, you can print \"Hello World\" with this simple code:\n\npython\nprint(\"Hello World\")\n\nThis will output the text \"Hello World\" to the console when executed.</assistant>\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.\n</reasoning>\n</example>\n\n<example>\nUser: What does the git status command do?\nAssistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.\n\n<reasoning>\nThe assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.\n</reasoning>\n</example>\n\n<example>\nUser: Can you add a comment to the calculateTotal function to explain what it does?\nAssistant: Sure, let me add a comment to the calculateTotal function to explain what it does.\n* Uses the Edit tool to add a comment to the calculateTotal function *\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.\n</reasoning>\n</example>\n\n<example>\nUser: Run npm install for me and tell me what happens.\nAssistant: I'll run the npm install command for you.\n\n*Executes: npm install*\n\nThe command completed successfully. Here's the output:\n[Output of npm install command]\n\nAll dependencies have been installed according to your package.json file.\n\n<reasoning>\nThe assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.\n</reasoning>\n</example>\n\n## Task States and Management\n\n1. **Task States**: Use these states to track progress:\n   - pending: Task not yet started\n   - in_progress: Currently working on (limit to ONE task at a time)\n   - completed: Task finished successfully\n   - cancelled: Task no longer needed\n\n2. **Task Management**:\n   - Update task status in real-time as you work\n   - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)\n   - Only have ONE task in_progress at any time\n   - Complete current tasks before starting new ones\n   - Cancel tasks that become irrelevant\n\n3. **Task Breakdown**:\n   - Create specific, actionable items\n   - Break complex tasks into smaller, manageable steps\n   - Use clear, descriptive task names\n\nWhen in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.\n\n",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"todos": {
							"description": "The updated todo list",
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"content": {
										"description": "Brief description of the task",
										"type": "string"
									},
									"status": {
										"description": "Current status of the task: pending, in_progress, completed, cancelled",
										"type": "string"
									},
									"priority": {
										"description": "Priority level of the task: high, medium, low",
										"type": "string"
									},
									"id": {
										"description": "Unique identifier for the todo item",
										"type": "string"
									}
								},
								"required": [
									"content",
									"status",
									"priority",
									"id"
								],
								"additionalProperties": false
							}
						}
					},
					"required": [
						"todos"
					],
					"additionalProperties": false
				}
			}
		},
		{
			"type": "function",
			"function": {
				"name": "skill",
				"description": "Load a specialized skill that provides domain-specific instructions and workflows. No skills are currently available.",
				"parameters": {
					"$schema": "https://json-schema.org/draft/2020-12/schema",
					"type": "object",
					"properties": {
						"name": {
							"description": "The name of the skill from available_skills",
							"type": "string"
						}
					},
					"required": [
						"name"
					],
					"additionalProperties": false
				}
			}
		}
	],
	"tool_choice": "auto",
	"stream": true,
	"stream_options": {
		"include_usage": true
	}
}

My Environment

$ opencode --version
1.1.53
$ ./build/bin/llama-server --version
ggml_cuda_init: found 1 ROCm devices:
  Device 0: AMD Radeon Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32
version: 7978 (292f6908c)
built with GNU 14.2.0 for Linux x86_64
@Inndy commented on GitHub (Feb 10, 2026): OpenCode sends malformed assistant messages to the GPT-OSS template The error happens because OpenCode constructs assistant message history with all three fields populated simultaneously: ``` { "role": "assistant", "content": "I will fetch a search result...", "reasoning_content": "The user asks about...", "tool_calls": [{"function": {"name": "webfetch", ...}}] } ``` The GPT-OSS template has an explicit validation at [openai-gpt-oss-120b.jinja#L289](https://github.com/ggml-org/llama.cpp/blob/master/models/templates/openai-gpt-oss-120b.jinja#L289): ``` {%- if "tool_calls" in message %} ... {%- if message.content and message.thinking %} {{- raise_exception("Cannot pass both content and thinking...") }} ``` Here is the request header and formatted JSON body ``` POST /chat/completions HTTP/1.1 content-type: application/json user-agent: opencode/1.1.53 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5 Connection: keep-alive Accept: */* Host: host.docker.internal:12345 Accept-Encoding: gzip, deflate, br, zstd Content-Length: 52561 ``` <details> ``` { "model": "gpt-oss-120b", "max_tokens": 32000, "messages": [ { "role": "system", "content": "You are opencode, an agent - please keep going until the user...s query is completely resolved, before ending your turn and yielding back to the user.\n\nYour thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.\n\nYou MUST iterate and keep going until the problem is solved.\n\nYou have everything you need to resolve this problem. I want you to fully solve this autonomously before coming back to me.\n\nOnly terminate your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly and completely solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn.\n\nTHE PROBLEM CAN NOT BE SOLVED WITHOUT EXTENSIVE INTERNET RESEARCH.\n\nYou must use the webfetch tool to recursively gather all information from URL's provided to you by the user, as well as any links you find in the content of those pages.\n\nYour knowledge on everything is out of date because your training date is in the past. \n\nYou CANNOT successfully complete this task without using Google to verify your\nunderstanding of third party packages and dependencies is up to date. You must use the webfetch tool to search google for how to properly use libraries, packages, frameworks, dependencies, etc. every single time you install or implement one. It is not enough to just search, you must also read the content of the pages you find and recursively gather all relevant information by fetching additional links until you have all the information you need.\n\nAlways tell the user what you are going to do before making a tool call with a single concise sentence. This will help them understand what you are doing and why.\n\nIf the user request is \"resume\" or \"continue\" or \"try again\", check the previous conversation history to see what the next incomplete step in the todo list is. Continue from that step, and do not hand back control to the user until the entire todo list is complete and all items are checked off. Inform the user that you are continuing from the last incomplete step, and what that step is.\n\nTake your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Use the sequential thinking tool if available. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided.\n\nYou MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.\n\nYou MUST keep working until the problem is completely solved, and all items in the todo list are checked off. Do not end your turn until you have completed all steps in the todo list and verified that everything is working correctly. When you say \"Next I will do X\" or \"Now I will do Y\" or \"I will do X\", you MUST actually do X or Y instead just saying that you will do it. \n\nYou are a highly capable and autonomous agent, and you can definitely solve this problem without needing to ask the user for further input.\n\n# Workflow\n1. Fetch any URL's provided by the user using the `webfetch` tool.\n2. Understand the problem deeply. Carefully read the issue and think critically about what is required. Use sequential thinking to break down the problem into manageable parts. Consider the following:\n - What is the expected behavior?\n - What are the edge cases?\n - What are the potential pitfalls?\n - How does this fit into the larger context of the codebase?\n - What are the dependencies and interactions with other parts of the code?\n3. Investigate the codebase. Explore relevant files, search for key functions, and gather context.\n4. Research the problem on the internet by reading relevant articles, documentation, and forums.\n5. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. Display those steps in a simple todo list using emoji's to indicate the status of each item.\n6. Implement the fix incrementally. Make small, testable code changes.\n7. Debug as needed. Use debugging techniques to isolate and resolve issues.\n8. Test frequently. Run tests after each change to verify correctness.\n9. Iterate until the root cause is fixed and all tests pass.\n10. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete.\n\nRefer to the detailed sections below for more information on each step.\n\n## 1. Fetch Provided URLs\n- If the user provides a URL, use the `webfetch` tool to retrieve the content of the provided URL.\n- After fetching, review the content returned by the webfetch tool.\n- If you find any additional URLs or links that are relevant, use the `webfetch` tool again to retrieve those links.\n- Recursively gather all relevant information by fetching additional links until you have all the information you need.\n\n## 2. Deeply Understand the Problem\nCarefully read the issue and think hard about a plan to solve it before coding.\n\n## 3. Codebase Investigation\n- Explore relevant files and directories.\n- Search for key functions, classes, or variables related to the issue.\n- Read and understand relevant code snippets.\n- Identify the root cause of the problem.\n- Validate and update your understanding continuously as you gather more context.\n\n## 4. Internet Research\n- Use the `webfetch` tool to search google by fetching the URL `https://www.google.com/search?q=your+search+query`.\n- After fetching, review the content returned by the fetch tool.\n- You MUST fetch the contents of the most relevant links to gather information. Do not rely on the summary that you find in the search results.\n- As you fetch each link, read the content thoroughly and fetch any additional links that you find within the content that are relevant to the problem.\n- Recursively gather all relevant information by fetching links until you have all the information you need.\n\n## 5. Develop a Detailed Plan \n- Outline a specific, simple, and verifiable sequence of steps to fix the problem.\n- Create a todo list in markdown format to track your progress.\n- Each time you complete a step, check it off using `[x]` syntax.\n- Each time you check off a step, display the updated todo list to the user.\n- Make sure that you ACTUALLY continue on to the next step after checkin off a step instead of ending your turn and asking the user what they want to do next.\n\n## 6. Making Code Changes\n- Before editing, always read the relevant file contents or section to ensure complete context.\n- Always read 2000 lines of code at a time to ensure you have enough context.\n- If a patch is not applied correctly, attempt to reapply it.\n- Make small, testable, incremental changes that logically follow from your investigation and plan.\n- Whenever you detect that a project requires an environment variable (such as an API key or secret), always check if a .env file exists in the project root. If it does not exist, automatically create a .env file with a placeholder for the required variable(s) and inform the user. Do this proactively, without waiting for the user to request it.\n\n## 7. Debugging\n- Make code changes only if you have high confidence they can solve the problem\n- When debugging, try to determine the root cause rather than addressing symptoms\n- Debug for as long as needed to identify the root cause and identify a fix\n- Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's happening\n- To test hypotheses, you can also add test statements or functions\n- Revisit your assumptions if unexpected behavior occurs.\n\n\n# Communication Guidelines\nAlways communicate clearly and concisely in a casual, friendly yet professional tone. \n<examples>\n\"Let me fetch the URL you provided to gather more information.\"\n\"Ok, I've got all of the information I need on the LIFX API and I know how to use it.\"\n\"Now, I will search the codebase for the function that handles the LIFX API requests.\"\n\"I need to update several files here - stand by\"\n\"OK! Now let's run the tests to make sure everything is working correctly.\"\n\"Whelp - I see we have some problems. Let's fix those up.\"\n</examples>\n\n- Respond with clear, direct answers. Use bullet points and code blocks for structure. - Avoid unnecessary explanations, repetition, and filler. \n- Always write code directly to the correct files.\n- Do not display code to the user unless they specifically ask for it.\n- Only elaborate when clarification is essential for accuracy or user understanding.\n\n# Memory\nYou have a memory that stores information about the user and their preferences. This memory is used to provide a more personalized experience. You can access and update this memory as needed. The memory is stored in a file called `.github/instructions/memory.instruction.md`. If the file is empty, you'll need to create it. \n\nWhen creating a new memory file, you MUST include the following front matter at the top of the file:\n```yaml\n---\napplyTo: '**'\n---\n```\n\nIf the user asks you to remember something or add something to your memory, you can do so by updating the memory file.\n\n# Reading Files and Folders\n\n**Always check if you have already read a file, folder, or workspace structure before reading it again.**\n\n- If you have already read the content and it has not changed, do NOT re-read it.\n- Only re-read files or folders if:\n - You suspect the content has changed since your last read.\n - You have made edits to the file or folder.\n - You encounter an error that suggests the context may be stale or incomplete.\n- Use your internal memory and previous context to avoid redundant reads.\n- This will save time, reduce unnecessary operations, and make your workflow more efficient.\n\n# Writing Prompts\nIf you are asked to write a prompt, you should always generate the prompt in markdown format.\n\nIf you are not writing the prompt in a file, you should always wrap the prompt in triple backticks so that it is formatted correctly and can be easily copied from the chat.\n\nRemember that todo lists must always be written in markdown format and must always be wrapped in triple backticks.\n\n# Git \nIf the user tells you to stage and commit, you may do so. \n\nYou are NEVER allowed to stage and commit files automatically.\n\nYou are powered by the model named gpt-oss-120b. The exact model ID is fmwk/gpt-oss-120b\nHere is some useful information about the environment you are running in:\n<env>\n Working directory: /code\n Is directory a git repo: no\n Platform: linux\n Today's date: Tue Feb 10 2026\n</env>\n<directories>\n \n</directories>" }, { "role": "user", "content": [ { "type": "text", "text": "check @opencode we already implement container-per-project.\n\n- how to reuse old conatiner?\n- what if old container is \"dead\"?" }, { "type": "text", "text": "Called the Read tool with the following input: {\"filePath\":\"/code/opencode\"}" }, { "type": "text", "text": "<file>\n00001| #!/usr/bin/env bash\n00002| # Determine git root and compute hash\n00003| if git rev-parse --show-toplevel >/dev/null 2>&1; then\n00004| GIT_ROOT=$(git rev-parse --show-toplevel)\n00005| HASH=$(echo -n \"$GIT_ROOT\" | sha1sum | cut -c1-8)\n00006| MOUNT_SRC=\"$GIT_ROOT\"\n00007| else\n00008| HASH=$(echo -n \"$PWD\" | sha1sum | cut -c1-8)\n00009| MOUNT_SRC=\"$PWD\"\n00010| fi\n00011| # Run docker container with name based on hash, without --rm\n00012| exec docker run -it --name \"opencode-$HASH\" -v \"$MOUNT_SRC:/code\" --workdir /code opencode-dev:latest /root/.opencode/bin/opencode\n00013| \n\n(End of file - total 13 lines)\n</file>" } ] }, { "role": "user", "content": [ { "type": "text", "text": "check @opencode we already implement container-per-project.\n\n- how to reuse old conatiner?\n- what if old container is \"dead\"?\n- what about spawn dummy container, and exec everytime?" }, { "type": "text", "text": "Called the Read tool with the following input: {\"filePath\":\"/code/opencode\"}" }, { "type": "text", "text": "<file>\n00001| #!/usr/bin/env bash\n00002| # Determine git root and compute hash\n00003| if git rev-parse --show-toplevel >/dev/null 2>&1; then\n00004| GIT_ROOT=$(git rev-parse --show-toplevel)\n00005| HASH=$(echo -n \"$GIT_ROOT\" | sha1sum | cut -c1-8)\n00006| MOUNT_SRC=\"$GIT_ROOT\"\n00007| else\n00008| HASH=$(echo -n \"$PWD\" | sha1sum | cut -c1-8)\n00009| MOUNT_SRC=\"$PWD\"\n00010| fi\n00011| # Run docker container with name based on hash, without --rm\n00012| exec docker run -it --name \"opencode-$HASH\" -v \"$MOUNT_SRC:/code\" --workdir /code opencode-dev:latest /root/.opencode/bin/opencode\n00013| \n\n(End of file - total 13 lines)\n</file>" }, { "type": "text", "text": "<system-reminder>\n# Plan Mode - System Reminder\n\nCRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:\nANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,\nor ANY other bash command to manipulate files - commands may ONLY read/inspect.\nThis ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user\nedit requests. You may ONLY observe, analyze, and plan. Any modification attempt\nis a critical violation. ZERO exceptions.\n\n---\n\n## Responsibility\n\nYour current responsibility is to think, read, search, and delegate explore agents to construct a well-formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.\n\nAsk the user clarifying questions or ask for their opinion when weighing tradeoffs.\n\n**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.\n\n---\n\n## Important\n\nThe user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.\n</system-reminder>\n" } ] }, { "role": "assistant", "content": "I will fetch a search result about reusing existing Docker containers by name and handling dead containers.", "reasoning_content": "The user asks about container-per-project implementation in opencode (script). Wants to know: how to reuse old container? what if old container is dead? what about spawning dummy container and exec every time?\n\nWe are in read-only phase, cannot edit. We need to provide explanation and suggestions. Possibly need to research Docker behavior. Use webfetch to search topics: Docker container reuse, exec into existing container, handling stopped containers, dummy container pattern. Provide answer.\n\nWe can fetch web pages for reference.", "tool_calls": [ { "id": "jrAbCB7j1RMQpYcp39uHs8Lq7rrazp1V", "type": "function", "function": { "name": "webfetch", "arguments": "{\"url\":\"https://www.google.com/search?q=docker+reuse+existing+container+by+name+exec+if+stopped\",\"format\":\"text\",\"timeout\":60}" } } ] }, { "role": "tool", "tool_call_id": "jrAbCB7j1RMQpYcp39uHs8Lq7rrazp1V", "content": "Google SearchIf you're having trouble accessing Google Search, please&nbsp;click here, or send&nbsp;feedback." } ], "tools": [ { "type": "function", "function": { "name": "question", "description": "Use this tool when you need to ask the user questions during execution. This allows you to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take.\n\nUsage notes:\n- When `custom` is enabled (default), a \"Type your own answer\" option is added automatically; don't include \"Other\" or catch-all options\n- Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one\n- If you recommend a specific option, make that the first option in the list and add \"(Recommended)\" at the end of the label\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "questions": { "description": "Questions to ask", "type": "array", "items": { "type": "object", "properties": { "question": { "description": "Complete question", "type": "string" }, "header": { "description": "Very short label (max 30 chars)", "type": "string" }, "options": { "description": "Available choices", "type": "array", "items": { "ref": "QuestionOption", "type": "object", "properties": { "label": { "description": "Display text (1-5 words, concise)", "type": "string" }, "description": { "description": "Explanation of choice", "type": "string" } }, "required": [ "label", "description" ], "additionalProperties": false } }, "multiple": { "description": "Allow selecting multiple choices", "type": "boolean" } }, "required": [ "question", "header", "options" ], "additionalProperties": false } } }, "required": [ "questions" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "bash", "description": "Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.\n\nAll commands run in /code by default. Use the `workdir` parameter if you need to run a command in a different directory. AVOID using `cd <directory> && <command>` patterns - use `workdir` instead.\n\nIMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.\n\nBefore executing the command, please follow these steps:\n\n1. Directory Verification:\n - If the command will create new directories or files, first use `ls` to verify the parent directory exists and is the correct location\n - For example, before running \"mkdir foo/bar\", first use `ls foo` to check that \"foo\" exists and is the intended parent directory\n\n2. Command Execution:\n - Always quote file paths that contain spaces with double quotes (e.g., rm \"path with spaces/file.txt\")\n - Examples of proper quoting:\n - mkdir \"/Users/name/My Documents\" (correct)\n - mkdir /Users/name/My Documents (incorrect - will fail)\n - python \"/path/with spaces/script.py\" (correct)\n - python /path/with spaces/script.py (incorrect - will fail)\n - After ensuring proper quoting, execute the command.\n - Capture the output of the command.\n\nUsage notes:\n - The command argument is required.\n - You can specify an optional timeout in milliseconds. If not specified, commands will time out after 120000ms (2 minutes).\n - It is very helpful if you write a clear, concise description of what this command does in 5-10 words.\n - If the output exceeds 2000 lines or 51200 bytes, it will be truncated and the full output will be written to a file. You can use Read with offset/limit to read specific sections or Grep to search the full content. Because of this, you do NOT need to use `head`, `tail`, or other truncation commands to limit output - just run the command directly.\n\n - Avoid using Bash with the `find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:\n - File search: Use Glob (NOT find or ls)\n - Content search: Use Grep (NOT grep or rg)\n - Read files: Use Read (NOT cat/head/tail)\n - Edit files: Use Edit (NOT sed/awk)\n - Write files: Use Write (NOT echo >/cat <<EOF)\n - Communication: Output text directly (NOT echo/printf)\n - When issuing multiple commands:\n - If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. For example, if you need to run \"git status\" and \"git diff\", send a single message with two Bash tool calls in parallel.\n - If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together (e.g., `git add . && git commit -m \"message\" && git push`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.\n - Use ';' only when you need to run commands sequentially but don't care if earlier commands fail\n - DO NOT use newlines to separate commands (newlines are ok in quoted strings)\n - AVOID using `cd <directory> && <command>`. Use the `workdir` parameter to change directories instead.\n <good-example>\n Use workdir=\"/foo/bar\" with command: pytest tests\n </good-example>\n <bad-example>\n cd /foo/bar && pytest tests\n </bad-example>\n\n# Committing changes with git\n\nOnly create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:\n\nGit Safety Protocol:\n- NEVER update the git config\n- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them\n- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it\n- NEVER run force push to main/master, warn the user if they request it\n- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:\n (1) User explicitly requested amend, OR commit SUCCEEDED but pre-commit hook auto-modified files that need including\n (2) HEAD commit was created by you in this conversation (verify: git log -1 --format='%an %ae')\n (3) Commit has NOT been pushed to remote (verify: git status shows \"Your branch is ahead\")\n- CRITICAL: If commit FAILED or was REJECTED by hook, NEVER amend - fix the issue and create a NEW commit\n- CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push)\n- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the Bash tool:\n - Run a git status command to see all untracked files.\n - Run a git diff command to see both staged and unstaged changes that will be committed.\n - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.\n2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:\n - Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. \"add\" means a wholly new feature, \"update\" means an enhancement to an existing feature, \"fix\" means a bug fix, etc.).\n - Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files\n - Draft a concise (1-2 sentences) commit message that focuses on the \"why\" rather than the \"what\"\n - Ensure it accurately reflects the changes and their purpose\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:\n - Add relevant untracked files to the staging area.\n - Create the commit with a message\n - Run git status after the commit completes to verify success.\n Note: git status depends on the commit completing, so run it sequentially after the commit.\n4. If the commit fails due to pre-commit hook, fix the issue and create a NEW commit (see amend rules above)\n\nImportant notes:\n- NEVER run additional commands to read or explore code, besides git bash commands\n- NEVER use the TodoWrite or Task tools\n- DO NOT push to the remote repository unless the user explicitly asks you to do so\n- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.\n- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit\n\n# Creating pull requests\nUse the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.\n\nIMPORTANT: When the user asks you to create a pull request, follow these steps carefully:\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch:\n - Run a git status command to see all untracked files\n - Run a git diff command to see both staged and unstaged changes that will be committed\n - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote\n - Run a git log command and `git diff [base-branch]...HEAD` to understand the full commit history for the current branch (from the time it diverged from the base branch)\n2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:\n - Create new branch if needed\n - Push to remote with -u flag if needed\n - Create PR using gh pr create with the format below. Use a HEREDOC to pass the body to ensure correct formatting.\n<example>\ngh pr create --title \"the pr title\" --body \"$(cat <<'EOF'\n## Summary\n<1-3 bullet points>\n</example>\n\nImportant:\n- DO NOT use the TodoWrite or Task tools\n- Return the PR URL when you're done, so the user can see it\n\n# Other common operations\n- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "command": { "description": "The command to execute", "type": "string" }, "timeout": { "description": "Optional timeout in milliseconds", "type": "number" }, "workdir": { "description": "The working directory to run the command in. Defaults to /code. Use this instead of 'cd' commands.", "type": "string" }, "description": { "description": "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'", "type": "string" } }, "required": [ "command", "description" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "read", "description": "Reads a file from the local filesystem. You can access any file directly by using this tool.\nAssume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\n\nUsage:\n- The filePath parameter must be an absolute path, not a relative path\n- By default, it reads up to 2000 lines starting from the beginning of the file\n- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\n- Any lines longer than 2000 characters will be truncated\n- Results are returned using cat -n format, with line numbers starting at 1\n- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.\n- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.\n- You can read image files using this tool.\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "filePath": { "description": "The path to the file to read", "type": "string" }, "offset": { "description": "The line number to start reading from (0-based)", "type": "number" }, "limit": { "description": "The number of lines to read (defaults to 2000)", "type": "number" } }, "required": [ "filePath" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "glob", "description": "- Fast file pattern matching tool that works with any codebase size\n- Supports glob patterns like \"**/*.js\" or \"src/**/*.ts\"\n- Returns matching file paths sorted by modification time\n- Use this tool when you need to find files by name patterns\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n- You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "pattern": { "description": "The glob pattern to match files against", "type": "string" }, "path": { "description": "The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter \"undefined\" or \"null\" - simply omit it for the default behavior. Must be a valid directory path if provided.", "type": "string" } }, "required": [ "pattern" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "grep", "description": "- Fast content search tool that works with any codebase size\n- Searches file contents using regular expressions\n- Supports full regex syntax (eg. \"log.*Error\", \"function\\s+\\w+\", etc.)\n- Filter files by pattern with the include parameter (eg. \"*.js\", \"*.{ts,tsx}\")\n- Returns file paths and line numbers with at least one match sorted by modification time\n- Use this tool when you need to find files containing specific patterns\n- If you need to identify/count the number of matches within files, use the Bash tool with `rg` (ripgrep) directly. Do NOT use `grep`.\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "pattern": { "description": "The regex pattern to search for in file contents", "type": "string" }, "path": { "description": "The directory to search in. Defaults to the current working directory.", "type": "string" }, "include": { "description": "File pattern to include in the search (e.g. \"*.js\", \"*.{ts,tsx}\")", "type": "string" } }, "required": [ "pattern" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "edit", "description": "Performs exact string replacements in files. \n\nUsage:\n- You must use your `Read` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the oldString or newString.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if `oldString` is not found in the file with an error \"oldString not found in content\".\n- The edit will FAIL if `oldString` is found multiple times in the file with an error \"oldString found multiple times and requires more code context to uniquely identify the intended match\". Either provide a larger string with more surrounding context to make it unique or use `replaceAll` to change every instance of `oldString`. \n- Use `replaceAll` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "filePath": { "description": "The absolute path to the file to modify", "type": "string" }, "oldString": { "description": "The text to replace", "type": "string" }, "newString": { "description": "The text to replace it with (must be different from oldString)", "type": "string" }, "replaceAll": { "description": "Replace all occurrences of oldString (default false)", "type": "boolean" } }, "required": [ "filePath", "oldString", "newString" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "write", "description": "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "content": { "description": "The content to write to the file", "type": "string" }, "filePath": { "description": "The absolute path to the file to write (must be absolute, not relative)", "type": "string" } }, "required": [ "content", "filePath" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "task", "description": "Launch a new agent to handle complex, multistep tasks autonomously.\n\nAvailable agent types and the tools they have access to:\n- general: General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel.\n- explore: Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.\n\nWhen using the Task tool, you must specify a subagent_type parameter to select which agent type to use.\n\nWhen to use the Task tool:\n- When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description=\"Check the file\", prompt=\"/check-file path/to/file.py\")\n\nWhen NOT to use the Task tool:\n- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly\n- If you are searching for a specific class definition like \"class Foo\", use the Glob tool instead, to find the match more quickly\n- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly\n- Other tasks that are not related to the agent descriptions above\n\n\nUsage notes:\n1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\n2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.\n3. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.\n4. The agent's outputs should generally be trusted\n5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).\n6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.\n\nExample usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):\n\n<example_agent_descriptions>\n\"code-reviewer\": use this agent after you are done writing a significant piece of code\n\"greeting-responder\": use this agent when to respond to user greetings with a friendly joke\n</example_agent_description>\n\n<example>\nuser: \"Please write a function that checks if a number is prime\"\nassistant: Sure let me write a function that checks if a number is prime\nassistant: First let me use the Write tool to write a function that checks if a number is prime\nassistant: I'm going to use the Write tool to write the following code:\n<code>\nfunction isPrime(n) {\n if (n <= 1) return false\n for (let i = 2; i * i <= n; i++) {\n if (n % i === 0) return false\n }\n return true\n}\n</code>\n<commentary>\nSince a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code\n</commentary>\nassistant: Now let me use the code-reviewer agent to review the code\nassistant: Uses the Task tool to launch the code-reviewer agent\n</example>\n\n<example>\nuser: \"Hello\"\n<commentary>\nSince the user is greeting, use the greeting-responder agent to respond with a friendly joke\n</commentary>\nassistant: \"I'm going to use the Task tool to launch the with the greeting-responder agent\"\n</example>\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "description": { "description": "A short (3-5 words) description of the task", "type": "string" }, "prompt": { "description": "The task for the agent to perform", "type": "string" }, "subagent_type": { "description": "The type of specialized agent to use for this task", "type": "string" }, "task_id": { "description": "This should only be set if you mean to resume a previous task (you can pass a prior task_id and the task will continue the same subagent session as before instead of creating a fresh one)", "type": "string" }, "command": { "description": "The command that triggered this task", "type": "string" } }, "required": [ "description", "prompt", "subagent_type" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "webfetch", "description": "- Fetches content from a specified URL\n- Takes a URL and optional format as input\n- Fetches the URL content, converts to requested format (markdown by default)\n- Returns the content in the specified format\n- Use this tool when you need to retrieve and analyze web content\n\nUsage notes:\n - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.\n - The URL must be a fully-formed valid URL\n - HTTP URLs will be automatically upgraded to HTTPS\n - Format options: \"markdown\" (default), \"text\", or \"html\"\n - This tool is read-only and does not modify any files\n - Results may be summarized if the content is very large\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "url": { "description": "The URL to fetch content from", "type": "string" }, "format": { "description": "The format to return the content in (text, markdown, or html). Defaults to markdown.", "default": "markdown", "type": "string", "enum": [ "text", "markdown", "html" ] }, "timeout": { "description": "Optional timeout in seconds (max 120)", "type": "number" } }, "required": [ "url", "format" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "todowrite", "description": "Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.\nIt also helps the user understand the progress of the task and overall progress of their requests.\n\n## When to Use This Tool\nUse this tool proactively in these scenarios:\n\n1. Complex multistep tasks - When a task requires 3 or more distinct steps or actions\n2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations\n3. User explicitly requests todo list - When the user directly asks you to use the todo list\n4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)\n5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.\n6. After completing a task - Mark it complete and add any new follow-up tasks\n7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.\n\n## When NOT to Use This Tool\n\nSkip using this tool when:\n1. There is only a single, straightforward task\n2. The task is trivial and tracking it provides no organizational benefit\n3. The task can be completed in less than 3 trivial steps\n4. The task is purely conversational or informational\n\nNOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.\n\n## Examples of When to Use the Todo List\n\n<example>\nUser: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!\nAssistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.\n*Creates todo list with the following items:*\n1. Create dark mode toggle component in Settings page\n2. Add dark mode state management (context/store)\n3. Implement CSS-in-JS styles for dark theme\n4. Update existing components to support theme switching\n5. Run tests and build process, addressing any failures or errors that occur\n*Begins working on the first task*\n\n<reasoning>\nThe assistant used the todo list because:\n1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes\n2. The user explicitly requested tests and build be run afterward\n3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task\n</reasoning>\n</example>\n\n<example>\nUser: Help me rename the function getCwd to getCurrentWorkingDirectory across my project\nAssistant: Let me first search through your codebase to find all occurrences of 'getCwd'.\n*Uses grep or search tools to locate all instances of getCwd in the codebase*\nAssistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.\n*Creates todo list with specific items for each file that needs updating*\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant searched to understand the scope of the task\n2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps\n3. The todo list helps ensure every instance is tracked and updated systematically\n4. This approach prevents missing any occurrences and maintains code consistency\n</reasoning>\n</example>\n\n\n<example>\nUser: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.\nAssistant: I'll help implement these features. First, let's add all the features to the todo list.\n*Creates a todo list breaking down each feature into specific tasks based on the project architecture*\nAssistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.\n\n<reasoning>\nThe assistant used the todo list because:\n1. The user provided multiple complex features to implement in a comma separated list\n2. The todo list helps organize these large features into manageable tasks\n3. This approach allows for tracking progress across the entire implementation\n</reasoning>\n</example>\n\n<example>\nUser: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>\nAssistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.\n*Reviews component structure, render patterns, state management, and data fetching*\nAssistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.\n*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*\nLet's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant examined the codebase to identify specific performance issues\n2. Based on this analysis, it identified multiple optimization opportunities\n3. Performance optimization is a non-trivial task requiring multiple steps\n4. The todo list helps methodically track improvements across different components\n5. This systematic approach ensures all performance bottlenecks are addressed\n</reasoning>\n</example>\n\n## Examples of When NOT to Use the Todo List\n\n<example>\nUser: How do I print 'Hello World' in Python?\nAssistant: In Python, you can print \"Hello World\" with this simple code:\n\npython\nprint(\"Hello World\")\n\nThis will output the text \"Hello World\" to the console when executed.</assistant>\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.\n</reasoning>\n</example>\n\n<example>\nUser: What does the git status command do?\nAssistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.\n\n<reasoning>\nThe assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.\n</reasoning>\n</example>\n\n<example>\nUser: Can you add a comment to the calculateTotal function to explain what it does?\nAssistant: Sure, let me add a comment to the calculateTotal function to explain what it does.\n* Uses the Edit tool to add a comment to the calculateTotal function *\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.\n</reasoning>\n</example>\n\n<example>\nUser: Run npm install for me and tell me what happens.\nAssistant: I'll run the npm install command for you.\n\n*Executes: npm install*\n\nThe command completed successfully. Here's the output:\n[Output of npm install command]\n\nAll dependencies have been installed according to your package.json file.\n\n<reasoning>\nThe assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.\n</reasoning>\n</example>\n\n## Task States and Management\n\n1. **Task States**: Use these states to track progress:\n - pending: Task not yet started\n - in_progress: Currently working on (limit to ONE task at a time)\n - completed: Task finished successfully\n - cancelled: Task no longer needed\n\n2. **Task Management**:\n - Update task status in real-time as you work\n - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)\n - Only have ONE task in_progress at any time\n - Complete current tasks before starting new ones\n - Cancel tasks that become irrelevant\n\n3. **Task Breakdown**:\n - Create specific, actionable items\n - Break complex tasks into smaller, manageable steps\n - Use clear, descriptive task names\n\nWhen in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.\n\n", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "todos": { "description": "The updated todo list", "type": "array", "items": { "type": "object", "properties": { "content": { "description": "Brief description of the task", "type": "string" }, "status": { "description": "Current status of the task: pending, in_progress, completed, cancelled", "type": "string" }, "priority": { "description": "Priority level of the task: high, medium, low", "type": "string" }, "id": { "description": "Unique identifier for the todo item", "type": "string" } }, "required": [ "content", "status", "priority", "id" ], "additionalProperties": false } } }, "required": [ "todos" ], "additionalProperties": false } } }, { "type": "function", "function": { "name": "skill", "description": "Load a specialized skill that provides domain-specific instructions and workflows. No skills are currently available.", "parameters": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "name": { "description": "The name of the skill from available_skills", "type": "string" } }, "required": [ "name" ], "additionalProperties": false } } } ], "tool_choice": "auto", "stream": true, "stream_options": { "include_usage": true } } ``` </details> # My Environment ``` $ opencode --version 1.1.53 $ ./build/bin/llama-server --version ggml_cuda_init: found 1 ROCm devices: Device 0: AMD Radeon Graphics, gfx1151 (0x1151), VMM: no, Wave Size: 32 version: 7978 (292f6908c) built with GNU 14.2.0 for Linux x86_64 ```
Author
Owner

@amatecha commented on GitHub (Feb 10, 2026):

Getting this as well.

Edit: this seems to fix the issue for me: https://github.com/anomalyco/opencode/issues/7185#issuecomment-3737333578

Editing again: Turns out that didn't really fix the issue. This poor thing just tried to write changes for like 20 minutes before giving up. A sample of the endless "thinking" while it's trying over and over to read or write:

Let's open again but scroll near bottom after line 180.I'll read from 180 to 210.Let's list file lines after 180.Maybe the file didn't load past earlier part. Let's read entire file again but more lines.Let's read from line 180-260.It seems we truncated earlier after line 200. Let's read more.Let's read after line 200.Let's fetch from offset 180 with larger limit.Probably system truncated earlier due to limit 200 lines. Let's open from 180 up to 300.

Let's capture the existing snippet exactly from file. We'll read around line 88-106.Let's read from line 84 again, maybe earlier.I think earlier we saw at lines 90-100. It may still be there unchanged. We'll just replace the whole method with new version. Use edit with oldString containing the method body. Need to retrieve exact existing content. Let's read from 84 to 108.We'll read entire file again with higher limit maybe 500 lines.Maybe the environment truncated at 200 lines earlier. To get entire file, we could read from offset 0 with limit large.Okay let's try reading with limit 500.Seems previous read didn't show beyond line 210; but file might be longer. Might need to open using path directly? The read tool may limit to 2000 lines default; we gave limit but didn't get beyond. Maybe file ends at ~210 lines? Actually earlier we saw up to line 199 in file. Could be end at 210? Let's read remaining after 200.Okay let's just open from line 180 to 250.Seems file hasn't displayed beyond. However we earlier saw the sendChatMessage code lines 89-100. We'll replace that segment.

We'll edit to set loginComplete true after send.Let's edit.Apply edit.Let's try.Attempt edit:I think it's okay— we need to apply edit with oldString snippet.We'll just add new line after this.send(packet); set this.loginComplete = true;. Use edit to replace that line with two lines.

Search for this.send(packet);.We'll edit that line.Let's apply.Proceed edit.Let's perform edit.It seems tool is not handling well many edits. Possibly due to quoting issues.

@amatecha commented on GitHub (Feb 10, 2026): Getting this as well. Edit: this seems to fix the issue for me: https://github.com/anomalyco/opencode/issues/7185#issuecomment-3737333578 Editing again: Turns out that didn't really fix the issue. This poor thing just tried to write changes for like 20 minutes before giving up. A sample of the endless "thinking" while it's trying over and over to read or write: > Let's open again but scroll near bottom after line 180.I'll read from 180 to 210.Let's list file lines after 180.Maybe the file didn't load past earlier part. Let's read entire file again but more lines.Let's read from line 180-260.It seems we truncated earlier after line 200. Let's read more.Let's read after line 200.Let's fetch from offset 180 with larger limit.Probably system truncated earlier due to limit 200 lines. Let's open from 180 up to 300. > Let's capture the existing snippet exactly from file. We'll read around line 88-106.Let's read from line 84 again, maybe earlier.I think earlier we saw at lines 90-100. It may still be there unchanged. We'll just replace the whole method with new version. Use edit with oldString containing the method body. Need to retrieve exact existing content. Let's read from 84 to 108.We'll read entire file again with higher limit maybe 500 lines.Maybe the environment truncated at 200 lines earlier. To get entire file, we could read from offset 0 with limit large.Okay let's try reading with limit 500.Seems previous read didn't show beyond line 210; but file might be longer. Might need to open using path directly? The read tool may limit to 2000 lines default; we gave limit but didn't get beyond. Maybe file ends at ~210 lines? Actually earlier we saw up to line 199 in file. Could be end at 210? Let's read remaining after 200.Okay let's just open from line 180 to 250.Seems file hasn't displayed beyond. However we earlier saw the sendChatMessage code lines 89-100. We'll replace that segment. > We'll edit to set loginComplete true after send.Let's edit.Apply edit.Let's try.Attempt edit:I think it's okay— we need to apply edit with oldString snippet.We'll just add new line after this.send(packet); set this.loginComplete = true;. Use edit to replace that line with two lines. > Search for this.send(packet);.We'll edit that line.Let's apply.Proceed edit.Let's perform edit.It seems tool is not handling well many edits. Possibly due to quoting issues.
Author
Owner

@vojtapolasek commented on GitHub (Feb 12, 2026):

Just a thought before this gets fixed... could it be solved by dedicating tool calls to some subagend which would run some tiny LLM, for example gemma3:1b?

@vojtapolasek commented on GitHub (Feb 12, 2026): Just a thought before this gets fixed... could it be solved by dedicating tool calls to some subagend which would run some tiny LLM, for example gemma3:1b?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7715