Skip to content

Direct Usage

Use --backend langchain to connect UCAgent directly to a model in one terminal. This backend binds the verification tools in process.

This guide runs toffee-ut:ut for a selected DUT. Its default output is <workspace>/ut_project/.

1. Configure the Model

Environment variables are recommended:

1
2
3
export OPENAI_MODEL="<model_name>"
export OPENAI_API_KEY="<api_key>"
export OPENAI_API_BASE="https://<provider>/v1"

UCAgent uses the OpenAI-compatible interface. The OPENAI_API_MODE for the LangChain backend defaults to auto: it probes the Responses API before the first model operation and falls back to Chat Completions only if the server explicitly does not support it. Set it to responses or chat_completions if you need to fix the protocol. OPENAI_REASONING_EFFORT defaults to xhigh; the value is passed to the server as-is, so please fill in a value supported by your model.

Configure an embedding model if you need semantic search or memory tools:

1
2
3
export EMBED_MODEL="<embedding_model>"
export EMBED_OPENAI_API_KEY="$OPENAI_API_KEY"
export EMBED_OPENAI_API_BASE="$OPENAI_API_BASE"

The default value for --no-embed-tools in the current CLI is true, meaning embedding tools are disabled by default. To enable them, pass the flag explicitly:

--no-embed-tools false

You can also write the same keys into the project config.yaml:

openai:
  model_name: "<model_name>"
  openai_api_key: "<api_key>"
  openai_api_base: "https://<provider>/v1"
  api_mode: auto
  reasoning_effort: xhigh
embed:
  model_name: "<embedding_model>"
  openai_api_key: "<api_key>"
  openai_api_base: "https://<provider>/v1"
  dims: 4096

The configuration file supports environment variable placeholders in the form $(NAME: default). For the hierarchical loading order, CLI override methods, and other model providers, see Parameter Description.

2. Prepare the Workspace

Prepare the RTL, specifications, and output/toffee_Adder/ workspace as shown in Normal Mode. ToffeeUT creates the native DUT package during the workflow's build stage.

3. Using the CLI Directly

Start the prepared workspace with the LangChain backend:

ucagent toffee-ut output/toffee_Adder Adder --agent-mode single \
  --backend langchain --tui --loop

If you omit --loop, enter loop in the TUI to start.

Common parameters:

  • --config <path>: Specifies the project configuration; if not specified, the hierarchical default configuration is used.
  • --output <name>: Changes the output directory under the workspace. ToffeeUT defaults to ut_project.
  • --human / -hm: Starts human-intervention mode.
  • --tui: Opens the TUI; if not using the TUI, you can use --web-console or --web-terminal.
  • --skip <index>, --unskip <index>: Controls stages by runtime stage index; the index is based on what is displayed in status/hmcheck_list.
  • --no-write <path ...>: Prohibits writing to existing files or directories within the workspace; wildcard paths can be used for non-existent targets. See Parameter Description for security restrictions.

4. Common Actions in the TUI

1
2
3
status
current_tips
loop

When a stage fails, wait for the active operation to end, inspect the files and next steps reported by the Checker, repair them, then invoke each command and wait for its result:

tool_invoke Check
tool_invoke Complete

If a check has no output, inspect the logs. Cancel active model/tool work with Ctrl+C or the HTTP operation API and wait for it to end. The following tool calls also use the model-operation slot and are rejected while it is busy:

tool_invoke StdCheck {"lines":-1}
tool_invoke KillCheck

For a complete command reference, see Human-Machine Collaborative Verification and TUI.

Model Request Failures and Retries

When a LangChain automatic loop receives a non-retryable HTTP 4xx rejection, it stops the current loop immediately and retains the original error for inspection. Correct the service URL, model/credentials, or conversation/tool messages, then enter loop again. HTTP 408, 409, 429, 5xx, and unclassified connection/runtime errors retain the existing retry limits and delays. A request may be retried after missing tool results have actually been recorded, so the model can handle the recorded tool failure. If a later request is still rejected without further recovery progress, the loop stops. Stopping retries does not clear the conversation, advance stages, or bypass Check, Complete, or human authorization.

5. Artifacts and Next Steps

Specifications, tests, and run receipts are under <workspace>/ut_project/. See Result Analysis and Workflow Summary for details.