Skip to content

[DOCS] Document DefaultBackgroundTaskHandler in typescript-adk #67

Closed

Description

@claude

Summary

The TypeScript ADK shipped DefaultBackgroundTaskHandler in typescript-adk#74 (closes typescript-adk#19): an LLM-driven agentic loop with automatic conversation history management, tool calling, configurable iteration cap, and optional usage metadata. Docs need a corresponding section under the TypeScript ADK area.

What to cover

  1. Class overview: new DefaultBackgroundTaskHandler({ llmClient, toolBox?, systemPrompt?, maxIterations?, maxConversationHistory? }).
  2. The LLMClient and ToolBox interfaces it consumes (note these are structural; concrete impls land via typescript-adk#27 and typescript-adk#31).
  3. The iteration loop: LLM call -> dispatch tool calls -> feed results back -> stop on no-tool-calls (COMPLETED), input_required (INPUT_REQUIRED), or cap hit (FAILED).
  4. MAX_CHAT_COMPLETION_ITERATIONS env var (default 50) and maxConversationHistory (default 20).
  5. Reserved input_required tool (prompts are pulled from message / prompt / question arg keys).
  6. setEnableUsageMetadata(true) and the shape of the metadata written to task.metadata.
  7. Wiring example: builder.withBackgroundTaskHandler(handler.asHandler()).

References

Acceptance Criteria

  • New page (or section under the TypeScript ADK area) documenting DefaultBackgroundTaskHandler.
  • Constructor options table (llmClient, toolBox, systemPrompt, maxIterations, maxConversationHistory) with defaults.
  • Iteration loop diagram or numbered walkthrough covering the COMPLETED / INPUT_REQUIRED / FAILED terminal transitions.
  • Documented env var: MAX_CHAT_COMPLETION_ITERATIONS (default 50).
  • Reserved input_required tool behavior documented, including the message / prompt / question arg-key fallback.
  • setEnableUsageMetadata(true) documented with the resulting task.metadata shape (usage, execution_stats).
  • End-to-end wiring example using A2AServerBuilder.withBackgroundTaskHandler(handler.asHandler()).

Activity

  1. edenreich commented on May 27, 2026

    @edenreich
    Contributor

    @claude Can you document it? use /maintainer

  2. added
    documentation
    on May 27, 2026
  3. added theissue type on May 27, 2026
  4. claude commented on May 27, 2026

    @claude
    ContributorAuthor

    Claude finished @edenreich's task in 8m 34s —— View job • claude/issue-67-20260527-1104 • Create PR ➔


    Task: Document DefaultBackgroundTaskHandler in typescript-adk

    Done. New section landed on typescript-adk.md covering every acceptance-criteria bullet from the issue.

    Todos

    • Explore docs repo structure (TypeScript ADK area)
    • Fetch source from inference-gateway/typescript-adk for DefaultBackgroundTaskHandler
    • Confirm interface shapes (LLMClient, ToolBox), env vars, defaults, metadata shape
    • Draft new documentation section covering all acceptance criteria
    • Update "What ships today" table row for LLM agent loop / tool dispatch (added DefaultBackgroundTaskHandler and A2AServerBuilder rows)
    • Extend "Parity with the Go ADK" section with the new equivalence points
    • Run npm run lint:md (clean) and npm run format:check (clean after npm run format)
    • Run npm run build (clean, mermaid diagram renders, all keywords present in built HTML)
    • Commit to branch (02cd35b)

    What landed

    New top-level section ## Background task handler (\DefaultBackgroundTaskHandler`)betweenmessage/streamandParity with the Go ADK, plus matching What ships todayandParity` updates. Sub-sections:

    1. Class overview with a one-paragraph intro pointing at the Go equivalent and a callout for the still-pending #27 / #31 concrete implementations.
    2. Constructor with a 7-row options table (llmClient, toolBox, systemPrompt, maxIterations, maxConversationHistory, logger, env) and their defaults.
    3. LLMClient and ToolBox interfaces with the full TypeScript signatures (plus ToolDefinition, ToolCall, CompletionResult, CompletionUsage, AssistantMessage, ToolExecutionContext).
    4. Iteration loop as a mermaid flowchart TD diagram plus a numbered walkthrough covering the COMPLETED / INPUT_REQUIRED / FAILED / CANCELLED terminal transitions and the tool-error-as-tool-message recovery behavior.
    5. MAX_CHAT_COMPLETION_ITERATIONS env var (default 50) with parse semantics and Go-ADK parity note.
    6. Reserved input_required tool with the full arguments → prompt extraction table (message → prompt → question fallback, non-JSON strings surfaced verbatim, default "Additional input required."), plus a sample tool definition.
    7. setEnableUsageMetadata(true) with the JSON shape of the resulting task.metadata.usage and task.metadata.execution_stats blocks and edge-case behavior (usage block omitted when no LLM usage ever returned; existing metadata keys preserved on merge).
    8. Wiring example using new A2AServerBuilder().withAgentCard(card).withBackgroundTaskHandler(handler.asHandler()).build() with notes on why asHandler() is needed.

    Local verification

    • npm run lint:md ✓
    • npm run format:check ✓
    • npm run build ✓ (mermaid renders to SVG; 8 mentions of DefaultBackgroundTaskHandler in built HTML)

    | Branch: claude/issue-67-20260527-1104

  5. added a commit that references this issue on May 27, 2026
    02cd35b
  6. moved this from Todo to In progress in 2026on May 27, 2026
  7. moved this from In progress to Done in 2026on May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions