Repository navigation
feat(opencode-agents): render agent instruction templates - #182
Conversation
8a74e40 to
62fb13a
Compare
jeffdupont
left a comment
There was a problem hiding this comment.
LGTM — rendering once in the handler matches the runner contract ("the handler owns the single parse_template pass") and the claude/langchain/openai handlers. A couple of things worth addressing, non-blocking:
-
Resolver-override claim in the docstring (
handler.py:694-695): it says rendering happens after the model resolver "so a caller system-prompt override written ontoconfigis what gets rendered", butModelResolverisCallable[[dict], tuple[str, str]]and nothing writesconfig["instructions"]. That only works if a custom resolver mutates its input — an undocumented side effect with no test. If downstream relies on it, please make it an explicit contract (documented onModelResolver+ a test where the resolver writesconfig["instructions"] = "Override {{x}}"), or preferably a dedicated override param; otherwise drop the claim. -
Configured
messagesaren't rendered (_user_prompt,handler.py:704-735): non-systemconfig["messages"]go throughcompose_historywithoutparse_template, unlike claude-agents (handler.py:369,388) and openai-agents (handler.py:178). Sincecollapse_messages_to_instructionsleaves messages intact wheninstructionsis set,"Assist {{caller_email}}"would reach OpenCode literally. Render config messages (keeping history/user input raw), or document that agent mode doesn't template them. -
Tests: consider covering
variables=None, nested{{user.name}}, an unknown placeholder left intact, and thatset_input_content_attributesreceives the rendered text.
Note this should land before (or with) #179, which removes the skip_judges guidance.
62fb13a to
fabccbd
Compare
|
Addressed in fabccbd. Left unmerged because the base is still #179.
OpenCode tests: 44 passed. |
fabccbd to
1513cf1
Compare
c8d2911 to
491939d
Compare
ef5e3fd to
76210d8
Compare
Non-system config messages go through parse_template. History and the user turn stay raw. The resolver is not a place that writes instructions.
76210d8 to
804822b
Compare
Decision
Render
{{variables}}in non-system config messages withparse_template. History and the user turn stay raw. Instruction rendering, including the judge prompt, is already on #179, which is merged to main.Why
Configured messages were posted with placeholders still in them. The other handlers render those messages. History and the latest user turn are already concrete text.
What this PR does not do
config["instructions"].ModelResolveronly returns a provider id and a model id.Next
Observability #2547 passes
base_urltocreate_opencode_handler. This PR's base is main.