Skip to content

fix(ai): invoke OpenClaw through its agent command - #1308

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-ai-invocation
Oct 23, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-ai-invocation

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The AI backend selected OpenClaw but ran the unsupported top-level -p option, so enrichment could never get a model reply. Invoke openclaw agent --session-id <fresh UUID> --message <prompt> instead. Each task has its own session, with no external-channel delivery flag; stdout remains the plain answer callers expect.

Type of Change

  • Bug fix

Test Plan

  • Focused regression evidence failed before the fix and passed afterward.
  • 19 tests across ai-client-openclaw.test.ts and ai-client.test.ts.
  • npm run build, npx tsc --noEmit, npm run lint, and git diff --check passed.
  • Real CLI after build, commit ee7739a:
npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/openclaw-ai-import.test.ts
1 passed: real `teamai import --dir <fixture> --output <fixture> --all` with only a fixture OpenClaw CLI discoverable. The fixture rejects unsupported argv, records each independent session, and returns deterministic model output. The imported _domains.json contains the inferred openclaw-proof domain.

Related Issues

Related to #1221, one specific item in "Other findings". This PR does not close the umbrella issue or include its descriptor/resolver redesign.

Notes for Reviewers

Syntax checked against OpenClaw agent documentation and its agent-via-gateway source. No live model tokens were used; the test exercises the built TeamAI CLI and OS subprocess boundary with a fake OpenClaw response. Other backends' argv, output/error handling and timeouts stay unchanged.

Integration verification: all five independent fixes cherry-picked cleanly onto origin/main in a local-only checkout; combined build, typecheck and lint passed, with 174 unit tests and 7 real-CLI cases across 6 E2E files. The Windows test-list guard and moved POSIX command regression also pass together (25 tests).

- Use openclaw agent --message instead of the unsupported top-level -p option, keeping prompt text as one argument.
- Give every AI task a fresh UUID session so parallel enrichment never shares the member's conversation or requests external reply delivery.
- Preserve the existing plain-text response, process error and timeout handling for callers and other CLI backends.
- Verify 19 AI-client tests, build, typecheck and lint, and a real-CLI code import with an isolated OpenClaw fixture producing the inferred domain metadata. Related to Tencent#1221.
@github-actions

Copy link
Copy Markdown

No confident findings in the PR’s three-file diff.

  • The description documents sufficient testing: a built, real teamai import run through the subprocess boundary with a fixture OpenClaw CLI. This satisfies the required representative e2e record.
  • No earlier findings were provided.
  • Nothing from the PR was run, built, or installed.

The checkout’s shallow history prevented the three-dot command; I reconstructed the PR diff using the verified common parent, 97f1e7b.

@SaulMoro SaulMoro 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.

This was generated by AI during triage.

@nateEc Thanks, approving. This closes the #1221 item "ai-client runs openclaw -p, which OpenClaw does not accept".

We ran teamai import with the built CLI on this head and on its base 97f1e7b4, against a stand-in openclaw that logs its argv:

build argv sent result
base -p <prompt>, four times every call fails (unsupported argv), no domain written
this PR agent --session-id <uuid> --message <prompt>, four distinct UUIDs _domains.json has the stand-in's domain

Both runs exit 0. tsc, lint, the unit tests and the new e2e pass. Both new test files fail on the base.

Not blocking:

  • [P2 non-blocking] callClaude builds its error from stderr only (src/utils/ai-client.ts:153-154). If openclaw agent reports a failure on stdout, the message is just AI call failed: . We read this from OpenClaw's package, not from a real run.
  • [P2 non-blocking] Each call creates a new OpenClaw session that persists after the run. A sentence in the body or docs would help, and so would saying whether openclaw agent needs the Gateway running for a headless import.
  • [P3 nit] Two JSDoc blocks in ai-client.ts still list -p as the call form.

@SaulMoro
SaulMoro merged commit dd62c7a into Tencent:main Oct 23, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
- Use openclaw agent --message instead of the unsupported top-level -p option, keeping prompt text as one argument.
- Give every AI task a fresh UUID session so parallel enrichment never shares the member's conversation or requests external reply delivery.
- Preserve the existing plain-text response, process error and timeout handling for callers and other CLI backends.
- Verify 19 AI-client tests, build, typecheck and lint, and a real-CLI code import with an isolated OpenClaw fixture producing the inferred domain metadata. Related to Tencent#1221.
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.

3 participants