Skip to content

Conversation

@tcdent
Copy link
Contributor

@tcdent tcdent commented Jan 16, 2026

Add a JSON metadata field to activity records that can be set when enqueueing tasks and used for filtering in list/detail views.

Changes:

  • Add metadata_ column (JSON) to Activity model
  • Update Activity.get_list() and get_by_agent_id() with metadata filtering
  • Add metadata field to ActivityDetailSchema and ActivityListItemSchema
  • Update activity.create/list/detail tracker functions with metadata params
  • Update Task.create() to accept and pass through metadata
  • Update queue.enqueue() to accept metadata parameter
  • Update Pipeline.enqueue() to accept metadata parameter
  • Add comprehensive tests for metadata functionality
  • Add multi-tenancy example demonstrating the feature

Usage:
task = await ax.enqueue( "process_document", context, metadata={"organization_id": "org-123"} )

activities = activity.list( session, metadata_filter={"organization_id": "org-123"} )

Add a JSON metadata field to activity records that can be set when
enqueueing tasks and used for filtering in list/detail views.

Changes:
- Add metadata_ column (JSON) to Activity model
- Update Activity.get_list() and get_by_agent_id() with metadata filtering
- Add metadata field to ActivityDetailSchema and ActivityListItemSchema
- Update activity.create/list/detail tracker functions with metadata params
- Update Task.create() to accept and pass through metadata
- Update queue.enqueue() to accept metadata parameter
- Update Pipeline.enqueue() to accept metadata parameter
- Add comprehensive tests for metadata functionality
- Add multi-tenancy example demonstrating the feature

Usage:
  task = await ax.enqueue(
      "process_document",
      context,
      metadata={"organization_id": "org-123"}
  )

  activities = activity.list(
      session,
      metadata_filter={"organization_id": "org-123"}
  )
Add brief mentions of the metadata parameter for multi-tenancy:
- New "Activity Metadata" section in Supported Patterns
- Add metadata field to database schema docs
- Update Module Reference for enqueue, activity.list/detail, pipeline
- Link to multi-tenancy example
Metadata is now excluded from model_dump() and JSON serialization to
prevent accidental leakage of tenant info through API responses.

The field is still accessible as an attribute for programmatic use
(e.g., item.metadata), but won't appear in API responses unless
explicitly included by the user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants