Skip to content

docs(custom-engine): cover headless adapter pitfalls and add a ZCode example - #401

Merged
zpzjzj merged 6 commits into
alibaba:mainfrom
Walternater:docs/custom-engine-zcode
Nov 24, 2026
Merged

zpzjzj merged 6 commits into
alibaba:mainfrom
Walternater:docs/custom-engine-zcode

Conversation

@Walternater

Copy link
Copy Markdown
Contributor

Summary

Document the two headless pitfalls that cost a custom-engine adopter the most time, and add a worked ZCode CLI configuration as a starting point.

  • A local adapter that spawns the agent CLI with an open stdin pipe can block until the case deadline with no output; several CLIs read the open pipe as "waiting for input". The checklist now says to close or redirect the child's stdin unless the protocol needs it.
  • Headless runs have nobody to answer interactive approval prompts or questions, so only cases that cross an approval point hang while simple cases pass. The checklist now says to run the agent in its most autonomous permission mode and disable question tools where the CLI has a flag for that, and to keep the stdout tail in failure messages so an empty timeout is diagnosable.
  • docs/design/custom-engine.md gains a ZCode CLI example: the flag mapping (-p, --json, --resume, --cwd, --mode, --disallowed-tools), the engine.custom YAML, and the known limitation that headless ZCode resolves its model from the personal channel's providerOrder with no per-run --model flag, so ${model} cannot be forwarded.
  • Both writing-evals guides point at the checklist from the Custom Engine section.

Related issues

Refs #377. This follows the maintainer preference there for closing the gap with docs and a configuration example rather than a built-in engine.

Test plan

  • npm run docs:build → build complete, no broken-link warnings.
  • No code changes; make verify is unaffected.

Notes

The example reuses the reference adapter attached to #377 (not vendored here); the adapter path is resolved inside the runtime workspace, so adopters ship it with the skill. The interactive-prompt and stdin advice applies to every custom engine, not just ZCode.

Disclosure

Prepared with DeepSeek Harness (deepseek-v4.1-flash) as the coding agent; the example and the claims above were checked against the issue report and the design document, not against a live ZCode install.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T07:06:40.283467Z dfc6c14 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfc6c141ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/design/custom-engine.md Resolved
Walternater added a commit to Walternater/skill-up that referenced this pull request Nov 13, 2026
Recommending the CLI's most autonomous permission mode in the adapter
checklist and the ZCode example removed approval prompts without saying
anything about isolation. The default environment.type: none executes the
CLI directly on the host, so yolo-style modes hand shell and file tools
host privileges. Spell out that the mode needs environment.type: docker /
opensandbox or an explicit tool allowlist, and point at build/guarded plus
a narrower --disallowed-tools list for runs on none.

Reported in review of alibaba#401.
@zpzjzj

zpzjzj commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for adding the headless integration guidance and the isolation warnings. One issue remains in the ZCode YAML example in docs/design/custom-engine.md: it passes --output ${output_file} to the adapter, but does not configure engine.custom.local.output_file.

The reference adapter in #377 writes the SessionResult to that file and does not print it to stdout. However, CustomAgent.readRawResult only reads the result file when local.output_file is explicitly configured; otherwise it reads stdout. As written, the example therefore cannot return a usable SessionResult even when ZCode completes successfully.

Please add the following under engine.custom.local, alongside cwd:

output_file: ${output_file}

I verified this behavior against the implementation and ran the focused stdout/output-file tests, which passed. I have not run a live ZCode integration. The current CI and CLA checks are passing. I recommend fixing this configuration issue before merging.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output-file configuration issue described in #401 (comment) is still present at this head. The ZCode example passes --output ${output_file}, but does not set engine.custom.local.output_file. The referenced adapter writes its SessionResult only to that file, while CustomAgent.readRawResult returns stdout when custom.Local.OutputFile is empty. Consequently the copied example cannot read the successful result.

Please add output_file: ${output_file} under engine.custom.local, alongside cwd, before merging. The isolation warning is already addressed; this request is specifically for the remaining result-delivery mismatch. Verified against the latest example, the referenced adapter, and the result-reading implementation; no live ZCode integration was run in this review.

@Walternater

Copy link
Copy Markdown
Contributor Author

Added in aa43b78. The ZCode example now sets output_file: ${output_file} under engine.custom.local, next to cwd, and says why it repeats the --output argument: the adapter writes its SessionResult to that file, and CustomAgent.readRawResult (internal/agent/custom.go:473-475) returns stdout when local.output_file is empty — so the example as written completed and then parsed nothing.

I traced the path before editing rather than only pasting the line: prepareLocalFiles (custom.go:1186-1196) defaults the output path to outputs/session-result.json inside the runtime workspace and only renders local.output_file when it is set, so ${output_file} in the config resolves to the same path the adapter is told to write. Docker/opensandbox DownloadFile reads that path back; none reads it from the workspace directly.

I also folded the general rule into the integration checklist ("It returns a parseable SessionResult … the config reads it from where the adapter writes it: a local adapter that writes a file needs local.output_file"), so the next adapter author does not meet the same trap from the checklist alone. The existing response_format note in writing-evals.md already stated the stdout fallback; nothing there needed changing.

npm run docs:build passes. No live ZCode run — same gap as the rest of this PR, and I've kept it stated in the body.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj enabled auto-merge November 18, 2026 01:48
@zpzjzj

zpzjzj commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

The output-file issue is fixed, but I missed one documentation issue in my follow-up review: the current wording generalizes findings from Windows desktop CLI 0.17.1 in #377.

The ZCode v3.18.2 standalone configuration docs describe selecting a custom provider and model through a separate configuration file using ZCODE_PERSONAL_PROVIDER_CONFIG_FILE. This does not establish support for a --model flag or subscription-account models.

Before merging, please scope the model-selection limitation to the version and build actually tested, rather than stating that per-case model selection universally requires new CLI support. The documentation-based integration remains appropriate; there is no need to add a built-in engine for this.

I have left my GitHub approval unchanged.

…example

Local adapters can deadlock on an open child stdin and on interactive approval
prompts, and both failures surface as an empty timeout that looks like a slow
agent. Document the two pitfalls in the integration checklist, and add a
worked ZCode CLI configuration with its flag mapping so custom-engine authors
have a starting point (alibaba#377).
Recommending the CLI's most autonomous permission mode in the adapter
checklist and the ZCode example removed approval prompts without saying
anything about isolation. The default environment.type: none executes the
CLI directly on the host, so yolo-style modes hand shell and file tools
host privileges. Spell out that the mode needs environment.type: docker /
opensandbox or an explicit tool allowlist, and point at build/guarded plus
a narrower --disallowed-tools list for runs on none.

Reported in review of alibaba#401.
auto-merge was automatically disabled November 19, 2026 12:40

Head branch was pushed to by a user without write access

@Walternater
Walternater force-pushed the docs/custom-engine-zcode branch from aa43b78 to e3c8aa4 Compare November 19, 2026 12:40
@zpzjzj

zpzjzj commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Thanks for scoping the ZCode limitations to the tested version in e3c8aa4. Two changes would make the example safe to copy before merge: (1) the YAML example enables yolo but does not select an isolated environment; make the copyable example use a restricted mode or show the isolation configuration alongside yolo; (2) the model-selection note should say that the wrapper must explicitly parse and forward the model option. Adding it to local.args alone only passes it to the wrapper; the reference adapter does not forward arbitrary options to ZCode.

The example enabled the yolo mode without selecting an isolating runtime,
so copying it ran ZCode on the host with its privileges. The example now
carries the environment block that isolates it.

The model-selection note also claimed that a model flag passes through
`args`, but `local.args` only reaches the wrapper: the reference adapter
does not forward arbitrary options to ZCode, so the wrapper has to parse
and forward the option itself.

Co-Authored-By: Claude Code <[email protected]>
@Walternater

Copy link
Copy Markdown
Contributor Author

Both changes are in 8dd19cd.

(1) The example now selects an isolating runtime. The YAML snippet carries an environment block (type: docker, image: node:22) next to the engine block, so copying it runs the yolo mode under an isolated runtime rather than on the host. The kwargs.mode comment points at it.

(2) The model-selection note now says the wrapper has to forward the option itself. It no longer claims that a model flag passes through args: local.args only hands the value to the wrapper, and the reference adapter does not pass arbitrary options through to ZCode, so the wrapper has to parse the option and forward it to the CLI itself.

Comment thread docs/design/custom-engine.md Resolved
The stock node:22 image carries Node.js but no ZCode, and ${ZCODE_CLI} is
expanded on the host when the config loads, so a host install path never
reaches the container. Document the image that carries a ZCode build, point
ZCODE_CLI at the in-container path, and name the Windows fallback of the
reference adapter.

Co-Authored-By: Claude Code <[email protected]>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Walternater
❌ wangchongfei
You have signed the CLA already but the status is still pending? Let us recheck it.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 24, 2026
Merged via the queue into alibaba:main with commit 18160be Nov 24, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants