Skip to content

docs: add cookbook for tool calling and LLM patterns#49

Open
obrutjack wants to merge 1 commit intoopenclaw:mainfrom
obrutjack:docs/tool-calling-cookbook
Open

docs: add cookbook for tool calling and LLM patterns#49
obrutjack wants to merge 1 commit intoopenclaw:mainfrom
obrutjack:docs/tool-calling-cookbook

Conversation

@obrutjack
Copy link
Copy Markdown

Closes #26

Adds a Cookbook section to the README with common workflow patterns:

  • Which command to use — table clarifying llm.invoke vs llm_task.invoke vs openclaw.invoke
  • Fetch → LLM summarize — minimal two-step example
  • Three-step chain — fetch → LLM → save result
  • Approval gate — human confirmation before LLM call
  • Shell-safe args — using env vars instead of raw ${arg} substitution

This directly addresses the confusion in #26 where the user couldn't figure out the correct syntax for calling LLMs mid-workflow.

Copy link
Copy Markdown

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

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: 3396dca6a0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Q: "$LOBSTER_ARG_QUESTION"
run: >
openclaw.invoke --tool llm-task --action json
--args-json "{\"prompt\":\"$Q\"}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Build args JSON safely from env variables

This example is labeled as shell-safe for quotes/special characters, but --args-json "{\"prompt\":\"$Q\"}" still inlines $Q into a JSON string without escaping. If question contains a double quote (e.g. He said "hi"), the resulting JSON becomes invalid and openclaw.invoke fails with --args-json must be valid JSON, so the documented “safe” pattern breaks on common inputs. Use a JSON encoder (for example via jq --arg) instead of manual string interpolation.

Useful? React with 👍 / 👎.

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.

doc request: Need better examples for tool calling and llm_task in the middle

1 participant