> ## Documentation Index
> Fetch the complete documentation index at: https://docs.framework.vibeworkapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentHandle API

> Methods for communicating with running agents

## Sending Input

### send\_input

```rust theme={null}
handle.send_input("Hello!").await?;
```

Send user message to agent.

### send

```rust theme={null}
handle.send(InputMessage::UserInput("Hello!".to_string())).await?;
```

Send any `InputMessage` variant.

## Permissions

### send\_permission\_response

```rust theme={null}
handle.send_permission_response(
    "Bash",      // tool_name
    true,        // allowed
    false        // remember
).await?;
```

Respond to permission request.

### set\_dangerous\_skip\_permissions

```rust theme={null}
handle.set_dangerous_skip_permissions(true).await?;
```

Toggle permission bypass at runtime.

### is\_dangerous\_skip\_permissions\_enabled

```rust theme={null}
let bypassed = handle.is_dangerous_skip_permissions_enabled().await;
```

Check if permissions are bypassed.

## Async Tools

### send\_tool\_result

```rust theme={null}
handle.send_tool_result(
    "tool_use_123",
    ToolResult::success("Done")
).await?;
```

Send result for async tool.

## Output Subscription

### subscribe

```rust theme={null}
let mut rx = handle.subscribe();

while let Ok(chunk) = rx.recv().await {
    match chunk {
        OutputChunk::TextDelta(text) => print!("{}", text),
        OutputChunk::Done => break,
        _ => {}
    }
}
```

Subscribe to output stream. MUST call before send\_input.

## State Management

### state

```rust theme={null}
let state = handle.state().await;
```

Get current `AgentState`.

### is\_idle / is\_processing / is\_done

```rust theme={null}
if handle.is_idle().await {
    // Agent is idle
}

if handle.is_processing().await {
    // Agent is working
}

if handle.is_done().await {
    // Agent finished
}
```

### session\_id

```rust theme={null}
let id = handle.session_id();
```

Get session ID.

## Control

### interrupt

```rust theme={null}
handle.interrupt().await?;
```

Cancel current operation gracefully.

### shutdown

```rust theme={null}
handle.shutdown().await?;
```

Stop agent and clean up.

## Metadata

### set\_custom\_metadata

```rust theme={null}
handle.set_custom_metadata(
    "working_folder",
    "/path/to/project"
).await?;
```

Update session metadata (works on running agent).

### get\_custom\_metadata

```rust theme={null}
let folder = handle.get_custom_metadata("working_folder").await;
```

Get custom metadata value.

### set\_conversation\_name

```rust theme={null}
handle.set_conversation_name("Debug Python Script").await?;
```

Set conversation name.

### conversation\_name

```rust theme={null}
let name = handle.conversation_name().await;
```

Get conversation name.

## Session Rules

### add\_session\_rule

```rust theme={null}
handle.add_session_rule(
    PermissionRule::allow_tool("Write")
).await?;
```

Add in-memory permission rule.
