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

# Inputs

> Read text, structured payloads, and input sources with useInput

`useInput()` reads the input that caused the current agent render. Use it to
include the current request in the instructions or change behavior based on
where the request came from.

```tsx theme={null}
import { useInput } from "@opencomputer/agent";

export default function Agent() {
  const input = useInput();
  return input.text
    ? `Help the user with this request: ${input.text}`
    : "Help the user with their request.";
}
```

`useCurrentInput()` is an alias for `useInput()`.

## Input shape

```ts theme={null}
interface AgentInput {
  readonly source: InputSource;
  readonly text?: string;
  readonly payload?: DataValue;
}
```

| Field     | Meaning                                               |
| --------- | ----------------------------------------------------- |
| `source`  | How the work entered the session                      |
| `text`    | Optional human-readable message                       |
| `payload` | Optional structured JSON value supplied by the source |

`DataValue` means any JSON-compatible value: `null`, a boolean, number,
string, array, or object. Both `text` and `payload` are optional, so check them
before use.

## Adapt to the source

The current direct and delegated flows can share one agent definition:

```tsx theme={null}
import { useInput } from "@opencomputer/agent";

export default function Agent() {
  const input = useInput();

  return input.source === "subagent"
    ? "Complete the delegated task and return a concise result."
    : `Help with: ${input.text ?? "the current request"}`;
}
```

## Read structured payloads

Narrow or validate a payload before reading application-specific fields:

```tsx theme={null}
import { useInput } from "@opencomputer/agent";

type ResearchRequest = {
  topic?: string;
  depth?: "brief" | "deep";
};

export default function Agent() {
  const input = useInput();
  const request = (input.payload ?? {}) as ResearchRequest;

  if (request.topic) {
    return `Research ${request.topic} at ${request.depth ?? "brief"} depth.`;
  }

  return "Ask for a research topic before starting.";
}
```

Validate untrusted payloads in a tool before performing side effects.

## Input is not a prompt UI

`useInput()` only reads admitted input. It does not pause the session to ask a
person a question. The durable conversation and later messages are managed by
the [session](/agents/sessions).

Input payload also differs from [session data](/agents/session-data): a payload
belongs to the current input, while session data can persist across renders.
