You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `agents/` directory stores normal-looking AgentField nodes (complete with `if __name__ == "__main__"` hooks) that tests can import and run. Shared helpers such as the `run_agent_server` async context manager live in `utils/` so every test can start/stop agents the same way.
60
+
51
61
### Test Flow
52
62
53
63
1. Docker Compose starts the control plane (and PostgreSQL if needed)
@@ -176,46 +186,39 @@ make test-functional-local
176
186
177
187
## 🧪 Writing Tests
178
188
189
+
### Reusable Agent Nodes
190
+
191
+
- Put canonical agent implementations in `agents/<name>_agent.py`. Each module should expose a `create_agent(openrouter_config, **kwargs)` helper (see `agents/quick_start_agent.py`).
192
+
- Tests import those helpers, instantiate the agent (exactly like production code), and then spin it up with `utils.agent_server.run_agent_server`.
193
+
- Agent modules can also be executed directly (`python -m agents.quick_start_agent`) because they expose a `create_agent_from_env` helper.
194
+
179
195
### Basic Structure
180
196
181
197
```python
182
198
import pytest
183
-
from agentfield import Agent
199
+
from agents.my_agent import create_agent
200
+
from utils.agent_server import run_agent_server
184
201
185
202
@pytest.mark.functional
186
203
@pytest.mark.openrouter
187
204
@pytest.mark.asyncio
188
205
asyncdeftest_my_feature(
189
-
make_test_agent,
190
-
openrouter_config, # ALWAYS use this fixture - NEVER hardcode models
206
+
openrouter_config,
191
207
async_http_client,
192
208
):
193
-
# Create agent with OpenRouter config (uses OPENROUTER_MODEL env var)
194
-
agent = make_test_agent(
195
-
node_id="my-test-agent",
196
-
ai_config=openrouter_config, # This respects OPENROUTER_MODEL
> `make_test_agent` is still available for quick experiments, but we recommend capturing production-like agents under `agents/` so they can be reused across multiple tests or even run manually.
0 commit comments