Skip to main content
This feature is only available on v1.4.0-prerelease1 and above.

Overview

Agent Mode enables Bifrost to automatically execute tool calls without requiring explicit execution API calls for each tool. This transforms Bifrost from a simple gateway into an autonomous agent runtime.
Streaming Not Supported: Agent Mode is not compatible with streaming operations (chat_stream and responses_stream). Due to architectural limitations, the autonomous tool execution loop requires complete responses before proceeding to the next iteration (we cannot store all streaming chunks in memory just “in case” we get any tool calls, this would be a big anti-pattern). Use non-streaming endpoints (chat and responses) when Agent Mode is enabled.
When Agent Mode is enabled:
  1. LLM returns tool calls in its response
  2. Bifrost automatically executes auto-executable tools
  3. Results are fed back to the LLM
  4. Loop continues until no more tool calls OR max depth reached
  5. Non-auto-executable tools are returned to your application for approval
Agent Mode requires explicit configuration. Tools must be marked as auto-executable via tools_to_auto_execute. By default, no tools are auto-executed.

Configuration

Agent Mode requires two configurations:
  1. tools_to_execute: Which tools are available (whitelist)
  2. tools_to_auto_execute: Which tools can run automatically (subset of above)

Tools To Execute vs Tools To Auto Execute

A tool in tools_to_auto_execute that is NOT in tools_to_execute will be ignored. The execute list takes precedence.

Gateway Setup

Configuring Auto-Execute Tools

  1. Navigate to MCP Gateway in the left sidebar
  2. Click on a client to open its configuration sheet
  3. Scroll to the Available Tools section
  4. For each tool, toggle the Automatically execute tool switch
  5. Click Save Changes to apply
The auto-execute configuration is managed per-client, allowing fine-grained control over which tools run automatically vs. requiring manual approval.

Global Agent Settings

Configure max depth and other agent settings via:Gateway API:
config.json:

Go SDK Setup


Agent Mode Behavior

Max Depth

The max_agent_depth setting limits how many iterations the agent can perform:
  • Default: 10 iterations
  • Each LLM call that produces tool calls counts as one iteration
  • When max depth is reached, the current response is returned (may contain pending tool calls)

Parallel Execution

Auto-executable tools are executed in parallel for performance:

Mixed Auto/Non-Auto Tools

When a response contains both auto-executable and non-auto-executable tools:
  1. Auto-executable tools are executed first
  2. The response is returned with:
    • A text content field containing the executed tool results as JSON
    • Pending non-auto-executable tool calls in tool_calls
    • finish_reason set to "stop"
The content field contains a JSON summary of executed tool results. The tool_calls array contains only the non-auto-executable tools that require your approval. The finish_reason is set to "stop" to exit the agent loop.
Your application then:
  1. Parse the content field to see what was already executed
  2. Review the pending non-auto-executable tools in tool_calls
  3. Execute or reject them manually
  4. Continue the conversation with results

Security Considerations

Be careful which tools you mark as auto-executable. Dangerous operations like write_file, delete_file, execute_command should typically require human approval.
Safe for Auto-Execute:
  • Read operations (read_file, list_directory)
  • Search/query operations (search, fetch_url)
  • Non-destructive information gathering
Require Human Approval:
  • Write operations (write_file, create_file)
  • Delete operations (delete_file, delete_record)
  • Execute operations (run_command, execute_script)
  • Operations with side effects (sending emails, making purchases)

Example: Safe Configuration


Tool Execution Timeout

Individual tool executions are bounded by tool_execution_timeout:
  • Default: 30 seconds
  • If a tool exceeds the timeout, an error result is returned
  • The agent loop continues with the error result

Advanced: Agent Loop Internals

Iteration Tracking

When Agent Mode executes, each iteration through the LLM and tool execution cycle increments a counter. You can track this for logging and debugging:
The max_agent_depth setting controls maximum iterations:
  • Default: 10
  • Range: 1-50 (configurable)
  • When reached, current response returned as-is (may contain pending tool calls)

Custom Request ID Management

For complex workflows, track each iteration with unique request IDs:
This enables:
  • Audit trail of intermediate steps
  • Correlation of tool executions to iterations
  • Detailed observability for agent behavior

Parallel vs Sequential Execution

Auto-executable tools run in parallel for performance:
Non-auto-executable tools return immediately:

Response Format in Agent Mode

When Agent Mode finds mixed auto/non-auto tools:
The content field contains JSON summary of executed tool results. The tool_calls array contains only non-auto-executable tools.

Next Steps

Code Mode

Let AI write code to orchestrate multiple tools

Tool Filtering

Control tool availability per request