Skip to content

Callback Hooks for Dapr Agents #132

@bibryam

Description

@bibryam

Context
Dapr agents currently lack a built-in mechanism to intercept, observe, or modify execution flow at critical points, such as before/after LLM or tool calls. Introducing a standardized callback interface enhances extensibility, debugging, and control, enabling advanced use cases like auditing, response caching, guardrails, and dynamic modification of inputs/outputs.

Acceptance Criteria

  • Support four callback types:
  • before_llm_call(context): invoked before calling the LLM.
  • after_llm_call(context, response): invoked after receiving LLM response.
  • before_tool_call(context): invoked before invoking a tool.
  • after_tool_call(context, result): invoked after tool execution.
  • Each callback receives a context object with execution metadata (e.g., agent name, session ID, invocation details).

Callbacks can:

  • Log, inspect, or modify request data.
  • Return None to proceed or return a specific value to override execution.

Callback return behavior:

  • Returning a result from a before_* callback skips execution and uses that value.
  • Returning a result from an after_* callback replaces the original output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions