refactor(agent): align chat schema with full run agent input

This commit is contained in:
qzl
2026-03-03 15:29:46 +08:00
parent 5e169251fe
commit 17e6de177c
3 changed files with 70 additions and 0 deletions
@@ -0,0 +1,57 @@
from v1.agent.schemas import RunAgentInput
class TestRunAgentInput:
def test_requires_full_fields(self):
payload = {
"threadId": "t1",
"runId": "r1",
"state": {},
"messages": [],
"tools": [],
"context": [],
"forwardedProps": {},
}
model = RunAgentInput.model_validate(payload)
assert model.threadId == "t1"
assert model.runId == "r1"
assert model.parentRunId is None
assert model.state == {}
assert model.messages == []
assert model.tools == []
assert model.context == []
assert model.forwardedProps == {}
assert model.resume is None
def test_resume_optional(self):
payload = {
"threadId": "t1",
"runId": "r2",
"state": {},
"messages": [],
"tools": [],
"context": [],
"forwardedProps": {},
"resume": {"interruptId": "int-1", "payload": {"decision": "approved"}},
}
model = RunAgentInput.model_validate(payload)
assert model.resume is not None
assert model.resume["interruptId"] == "int-1"
assert model.resume["payload"]["decision"] == "approved"
def test_parent_run_id_optional(self):
payload = {
"threadId": "t1",
"runId": "r3",
"parentRunId": "p1",
"state": {"key": "value"},
"messages": [{"role": "user", "content": "hello"}],
"tools": [{"name": "ui.navigate_to"}],
"context": [{"type": "user", "id": "u1"}],
"forwardedProps": {"theme": "dark"},
}
model = RunAgentInput.model_validate(payload)
assert model.parentRunId == "p1"
assert model.state == {"key": "value"}
assert len(model.messages) == 1
assert model.messages[0]["role"] == "user"