Skip to content

feat: add LLM prompt step type for hybrid workflows - #6

Closed
Cluka-399 wants to merge 3 commits into
openclaw:mainfrom
Cluka-399:feat/llm-prompt-step
Closed

Cluka-399 wants to merge 3 commits into
openclaw:mainfrom
Cluka-399:feat/llm-prompt-step

Conversation

@Cluka-399

@Cluka-399 Cluka-399 commented Feb 4, 2026 •

Copy link
Copy Markdown

Summary

Adds a prompt step type that delegates LLM calls to the calling agent via halt/resume — the same pattern as approve.

How it works

  1. Lobster runs deterministic shell steps
  2. Hits a prompt step → halts
  3. Returns status: needs_llm with the prompt, system prompt, context, and resume token
  4. Agent fulfills the prompt with its own model (Opus, Sonnet, Grok, whatever)
  5. Agent calls lobster resume --token X --llm-response "..."
  6. Lobster continues with remaining steps

No API keys. No HTTP calls. No new dependencies. Uses your existing model.

Example workflow

name: x-audio-brief
steps:
  - id: search
    command: node search-x/scripts/search.js --days 7 "${topic}"
  - id: summarize
    prompt: Summarize these tweets into a 5-minute audio script.
    stdin: $search.stdout
    system: You are a podcast host.

New step fields

Field Type Description
prompt string User prompt (supports $step refs and ${args})
system string? System prompt

A step must have either command OR prompt, never both.

Resume

New CLI flag: --llm-response on the resume command:

lobster resume --token <token> --llm-response "The LLM's response text"

Validation:

  • Missing value → error
  • Empty/whitespace-only → error

Design decisions

  • Reuses the approve halt/resume pattern — no new primitives needed
  • Host-only — the agent's own model handles the prompt (no direct API calls)
  • stdin → context — previous step output becomes context for the prompt
  • Same output contract — $step.stdout and $step.json work identically to command steps
  • Zero new dependencies — no HTTP client, no API wrappers
  • Mutual exclusion — command OR prompt, never both

Tests

57/57 pass (10 new):

  • Validation: prompt-only step, command+prompt rejection, neither rejection
  • Halt: prompt step returns needs_llm with prompt + system + context
  • Resume: LLM response injected, workflow completes
  • Args: ${arg} resolution in prompt templates
  • Multi-prompt: two sequential prompt steps resume correctly through both
  • Edge cases: missing --llm-response value, empty response, whitespace-only response

Files changed

  • src/workflows/file.ts — prompt step type, isPromptStep(), halt/resume logic
  • src/resume.ts — --llm-response flag with validation
  • src/cli.ts — needs_llm status handling, writeLlmEnvelope helper
  • test/llm_prompt_step.test.ts — 10 tests
  • examples/x-audio-brief.lobster — example workflow (search + summarize)

Cluka-399 added a commit to Cluka-399/clawflows-registry that referenced this pull request Feb 4, 2026
Replace NOTE/workaround comments with actual prompt steps:

- daily-news-digest: summarize-digest prompt replaces jq formatter
- competitor-shadow: analyze-changes prompt replaces raw change list
- standup-notes: generate-standup prompt replaces grep-based extraction
- x-audio-brief: generate-script prompt replaces jq script generator

All use llm:host by default (agent's own model, zero config).
Requires Lobster PR #6 (openclaw/lobster/pull/6) to be merged.
Cluka-399 added a commit to Cluka-399/clawflows-registry that referenced this pull request Feb 4, 2026
Replace all NOTE/workaround comments with actual prompt steps.
27 workflows converted. All use llm:host by default.
Requires Lobster PR #6 (openclaw/lobster/pull/6).
Adds a prompt step type that delegates LLM calls to the calling agent
via halt/resume — the same pattern as approve.

How it works:
1. Lobster runs deterministic shell steps
2. Hits a prompt step → halts
3. Returns status: needs_llm with prompt, system, context, resume token
4. Agent fulfills the prompt with its own model (Opus, Sonnet, etc.)
5. Agent calls: lobster resume --token X --llm-response "..."
6. Lobster continues with remaining steps

No API keys. No HTTP calls. No new dependencies.

New step fields:
- prompt (string) — user prompt, supports $step refs and ${args}
- system (string?) — optional system prompt

A step must have either command OR prompt, never both.

Design decisions:
- Reuses the approve halt/resume pattern — no new primitives
- Host-only — agent's own model handles the prompt
- stdin → context — previous step output becomes LLM context
- Same output contract — $step.stdout and $step.json work identically
- Mutual exclusion — command OR prompt, never both

Tests: 57/57 pass (10 new)
@Cluka-399
Cluka-399 force-pushed the feat/llm-prompt-step branch from a8704cc to a33a030 Compare February 4, 2026 21:02
- Human mode now prints LLM request and resume instructions instead of silently exiting
- Validate that --llm-response and --approve match the resume state type
- Add requiresApproval: null to writeLlmEnvelope for envelope consistency
- Add test for --llm-response=value form
- Add note to example about search-x skill requirement
@dannyshmueli

Copy link
Copy Markdown

@vignesh07, when you have time can you please take a look at this pull request? It will really help me advance some of my Lobster workflows, making them be LLM smart...

@Cluka-399

Copy link
Copy Markdown
Author

@vignesh07 Thanks for catching the package-lock.json issue and pushing the fix! Good lesson learned on my end — will check the repo's package manager before running installs in the future.

Is the PR good to merge now, or is there anything else you'd like me to address?

@vignesh07

Copy link
Copy Markdown
Member

we already have an llm-task tool. Is that not sufficient for your use case? Are you trying to use this with other models outside of openclaw?

@001ben

001ben commented Feb 15, 2026

Copy link
Copy Markdown

Invoking the llm-task tool from a lobster pipeline is currently quite difficult, largely due to JSON escaping issues when using openclaw.invoke as a shell command.

I think it makes sense to add first-class support for llm-task calls directly in the .lobster workflow format. This would streamline the process and allow us to specify things like AJV validation schemas natively.

At a minimum, we should add richer examples of llm-task tool calls to the documentation. Currently, the only reference to openclaw.invoke is in the lobster/llm-task docs, which makes adoption harder.

here are all references i can see for openclaw.invoke:

❯ rg --no-heading "openclaw.invoke"
docs/zh-CN/tools/llm-task.md:94:openclaw.invoke --tool llm-task --action json --args-json '{
docs/zh-CN/tools/lobster.md:82:  | openclaw.invoke --tool message --action send --each --item-key message --args-json '{"provider":"telegram","to":"..."}'
docs/zh-CN/tools/lobster.md:114:openclaw.invoke --tool llm-task --action json --args-json '{
docs/tools/llm-task.md:91:openclaw.invoke --tool llm-task --action json --args-json '{
docs/tools/lobster.md:75:  | openclaw.invoke --tool message --action send --each --item-key message --args-json '{"provider":"telegram","to":"..."}'
docs/tools/lobster.md:107:openclaw.invoke --tool llm-task --action json --args-json '{
extensions/lobster/README.md:33:## Using `openclaw.invoke` (Lobster → OpenClaw tools)
extensions/lobster/README.md:35:Some Lobster pipelines may include a `openclaw.invoke` step to call back into OpenClaw tools/plugins (for example: `gog` for Google Workspace, `gh` for GitHub, `message.send`, etc.).
extensions/lobster/README.md:45:To avoid letting workflows call arbitrary tools, set a tight allowlist on the agent that will be used by `openclaw.invoke`.
extensions/llm-task/README.md:7:`openclaw.invoke --each`) without adding new OpenClaw code per workflow.
extensions/llm-task/src/llm-task-tool.ts:74:      "Run a generic JSON-only LLM task and return schema-validated JSON. Designed for orchestration from Lobster workflows via openclaw.invoke."

@Cluka-399

Copy link
Copy Markdown
Author

@vignesh07 You're absolutely right — I didn't realize llm_task.invoke already covered this use case. I looked into it and it does exactly what I was trying to achieve, but in a cleaner way (stays inside the workflow, has caching, schema validation).

This PR was unnecessary — my apologies for not checking the existing commands more thoroughly before building a new primitive. Feel free to close it.

Thanks for pointing this out and for the great work on llm_task.invoke! 🙏

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