Skip to content

Expose a public conversion seam for DatabaseTaskStore #1054

@liujuanjuan1984

Description

@liujuanjuan1984

Background

DatabaseTaskStore currently exposes useful advanced extension seams such as engine, initialize(), task_model, owner_resolver, and async_session_maker.

However, adapters that need to perform custom SQL persistence logic while still preserving the SDK's authoritative Task <-> ORM mapping currently have to call the private methods:

  • DatabaseTaskStore._to_orm(...)
  • DatabaseTaskStore._from_orm(...)

This works today, but it makes downstream integrations depend on private conversion helpers that may need rework on future SDK upgrades.

Why this matters

In some integrations, the need is not to replace the SDK's persistence policy, but to add a small amount of custom SQL behavior around it.

Examples include:

  • conditional/atomic upsert logic
  • adapter-side persistence guards
  • custom conflict handling that still wants to reuse the SDK's conversion hooks

Without a public conversion seam, downstream code has two options:

  1. Call the private methods.
  2. Reimplement the SDK's conversion logic locally.

Option 2 is usually worse, because it duplicates:

  • core_to_model_conversion
  • model_to_core_conversion
  • default protobuf JSON mapping
  • any legacy compatibility conversion behavior

Proposal

Expose a small public conversion seam for DatabaseTaskStore, for example:

  • to_task_model(task: Task, owner: str) -> TaskModel
  • from_task_model(task_model: TaskModel) -> Task

The exact names are not important, but the public contract would let advanced adapters reuse the SDK's authoritative conversions without depending on underscored methods.

These public methods could internally keep using the existing conversion flow:

  • core_to_model_conversion
  • model_to_core_conversion
  • the default built-in conversion behavior

Nice-to-have

If this direction makes sense, it may also be worth considering the same public conversion seam for DatabasePushNotificationConfigStore, which appears to have the same _to_orm() / _from_orm() pattern.

Non-goal

This is not a proposal to upstream adapter-specific task persistence policies or terminal-state guards. The request is only about making the conversion boundary explicit and public for advanced integrations.

Reference

Evaluated against local checkout:

  • a2aproject/a2a-python HEAD: 5f8fa229b376c09e754851683d12766b1abad314

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions