@@ -14,6 +14,19 @@ def __init__(
1414 should_populate_referred_tasks : bool = False ,
1515 task_store : TaskStore | None = None ,
1616 ) -> None :
17+ """Initializes the SimpleRequestContextBuilder.
18+
19+ Args:
20+ should_populate_referred_tasks: If True, the builder will fetch tasks
21+ referenced in `params.message.referenceTaskIds` and populate the
22+ `related_tasks` field in the RequestContext. Defaults to False.
23+ task_store: The TaskStore instance to use for fetching referred tasks.
24+ Required if `should_populate_referred_tasks` is True.
25+ """
26+ if should_populate_referred_tasks and not task_store :
27+ raise ValueError (
28+ 'task_store is required when should_populate_referred_tasks is True'
29+ )
1730 self ._task_store = task_store
1831 self ._should_populate_referred_tasks = should_populate_referred_tasks
1932
@@ -25,6 +38,23 @@ async def build(
2538 task : Task | None = None ,
2639 context : ServerCallContext | None = None ,
2740 ) -> RequestContext :
41+ """Builds the request context for an agent execution.
42+
43+ This method assembles the RequestContext object. If the builder was
44+ initialized with `should_populate_referred_tasks=True`, it fetches all tasks
45+ referenced in `params.message.referenceTaskIds` from the `task_store`.
46+
47+ Args:
48+ params: The parameters of the incoming message send request.
49+ task_id: The ID of the task being executed.
50+ context_id: The ID of the current execution context.
51+ task: The primary task object associated with the request.
52+ context: The server call context, containing metadata about the call.
53+
54+ Returns:
55+ An instance of RequestContext populated with the provided information
56+ and potentially a list of related tasks.
57+ """
2858 related_tasks : list [Task ] | None = None
2959
3060 if (
0 commit comments