This commit is contained in:
@@ -15,8 +15,10 @@ from typing import Any
|
||||
|
||||
from app.adk.runtime import (
|
||||
AgentTask,
|
||||
Answer,
|
||||
BudgetExhausted,
|
||||
Outcome,
|
||||
Question,
|
||||
RoleSpec,
|
||||
Stopped,
|
||||
ToolSpec,
|
||||
@@ -180,3 +182,27 @@ class FakeAgentRuntime:
|
||||
RunRecord(role.name, task, tuple(by_name), tuple(results), outcome)
|
||||
)
|
||||
return outcome
|
||||
|
||||
|
||||
class FakeDecider:
|
||||
"""A scripted Decider: answers by question id, or declines so callers fall back.
|
||||
|
||||
`answers` maps a question id to an Answer, or to a function of (state, question)
|
||||
returning one. An id with no entry makes the whole decision unavailable.
|
||||
"""
|
||||
|
||||
def __init__(self, answers: Mapping[str, Any] | None = None) -> None:
|
||||
self.answers = dict(answers or {})
|
||||
self.asked: list[tuple[str, dict[str, Question], str]] = []
|
||||
|
||||
async def decide(
|
||||
self, state: str, questions: Mapping[str, Question], *, scope: str = ""
|
||||
) -> Mapping[str, Answer] | None:
|
||||
self.asked.append((state, dict(questions), scope))
|
||||
decided = {}
|
||||
for name, question in questions.items():
|
||||
if name not in self.answers:
|
||||
return None
|
||||
answer = self.answers[name]
|
||||
decided[name] = answer(state, question) if callable(answer) else answer
|
||||
return decided
|
||||
|
||||
Reference in New Issue
Block a user