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

# LangChain Agent with Adapters

> Convert GroundForge Channel jobs and Agent results explicitly.

<Card title="groundforgeai/demo" icon="github" iconType="brands" href="https://github.com/groundforgeai/demo" horizontal cta="Open repository">
  The `simple_agent_service_adapter.py` example uses explicit input and output adapters.
</Card>

Complete [LangChain Agent Example](/examples/langchain-agent) first, then stop that process.

## Why use an adapter?

Automatic mode works when the Agent accepts normal message state and returns a normal final assistant message. Use adapters when your Agent expects a different state object or returns a custom result.

## Input adapter

The GroundForge job contains normalized input. The demo reads only the field it needs:

```python theme={null}
def channel_input(job):
    text = str(job.get("input") or "").strip()
    return {"messages": [{"role": "user", "content": text}]}
```

Do not assume fields such as `user_id`, tenant metadata, or application metadata unless your own Channel contract explicitly supplies them.

## Output adapter

```python theme={null}
def channel_output(result):
    final_message = result["messages"][-1]
    return {"text": final_message.content}
```

## Run the example

Use the same environment variables as the previous page:

```bash theme={null}
python simple_agent_service_adapter.py
```

Send the same weather question and open the Trace.

> **Screenshot placeholder**\
> Add `/images/examples/langchain-adapter-trace.png` showing Channel input, Agent execution, and Channel output.

Read [SDK Inputs and Outputs](/sdk/inputs) for the adapter hooks.


## Related topics

- [LangChain Agent Example](/examples/langchain-agent.md)
- [Agents](/concepts/agents.md)
- [Inputs and Outputs](/sdk/inputs.md)
- [Quick Start](/quickstart.md)
