Agent Interface
Implement the Agent interface to connect your browser agent to Trayn.
Interface
The Agent interface is the contract between your agent and the Trayn harness. Implement it to connect any agent framework to Trayn's training loop.
Methods
| Method | Required | Description |
|---|---|---|
get_action | Yes | Called each step with the current Observation. Returns an action string and AgentInfo. |
store_grades | Yes | Called after grading with a validated GradingResult. Use this to persist learned memories. |
reset | No | Called at the start of each task to reset agent state. |
init_session | No | Called at task start with run metadata (session, task, goal, URL). |
getRep | No | Returns the current repetition number. The harness uses this for memory-aware step IDs. |
AgentInfo
Return metadata alongside each action for logging and debugging.
AgentArgs
The harness takes an AgentArgs factory that creates your agent:
Example: Minimal Agent
Example: Agent with Memory
Use @trayn/memory to implement a learning agent that improves across repetitions:
The built-in TraynAgent already implements the full memory lifecycle. Use the examples above when building a custom agent with your own model and prompt strategy.