Skip to content

Conversation

@logan-markewich
Copy link
Collaborator

Initial stab at attaching arbitrary metadata to handlers

  • metadata is assigned when calling run()
  • if continuing a run/session, it will re-use existing metadata (or overwrite)
  • the list handlers endpoint now accepts basic filtering params

Concerns

  • this technically expands the db for persisted workflows. Do we need to worry about migrations? (sqlite is fine as is imo)
  • is there a better way to expose the filters?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18300062656

Details

  • 36 of 76 (47.37%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.8%) to 88.318%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/workflows/server/server.py 30 70 42.86%
Totals Coverage Status
Change from base Build 18291077207: -1.8%
Covered Lines: 1633
Relevant Lines: 1849

💛 - Coveralls

@logan-markewich logan-markewich added the enhancement New feature or request label Oct 7, 2025
@logan-markewich
Copy link
Collaborator Author

Hmm might need to try harder on tests

workflow_name: str
status: Status
ctx: dict[str, Any]
handler_metadata_json: str | None = Field(default=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the nested json? Can't this just be a dict[str, Any] (and default to {})?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly ease of storage lol but yes, good point

type: string
enum: [running, completed, failed, cancelled]
description: Filter by handler status
- in: query
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might make sense to make this consistent with the agent data query DSL https://developers.llamaindex.ai/python/cloud/llamaagents/agent-data-overview/#filter-dsl

I don't love that DSL, but there's not a lot of great options that don't explode in complexity. This DSL looks actually pretty similar? I would like to eventually move that agent data into the open source llamactl (or here?), so developing it out consistently should make it more re-usable and facilitate easier integration.

One difference here is that one is just using a POST to not have to get query parsing involved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're already parsing json in the query. Could just continue that pattern with the other dsl?


# Filter handlers
items = []
for wrapper in self._handlers.values():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really supporting completed workflows 😢 . Generally this querying seems like it should be pushed down into the persistence layer, at least in the long term, and we should push some of the state here in the server to an "in memory" persistence layer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang, yea, once workflows complete they get removed from this list

conn = sqlite3.connect(self.db_path)
conn.execute(
"CREATE TABLE IF NOT EXISTS handlers (handler_id TEXT PRIMARY KEY, workflow_name TEXT, status TEXT, ctx TEXT)"
"CREATE TABLE IF NOT EXISTS handlers (handler_id TEXT PRIMARY KEY, workflow_name TEXT, status TEXT, ctx TEXT, handler_metadata_json TEXT)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this will need a little mini migration, otherwise existing databases will crash and not support metadata. I like this for a no-dependency sqlite version migration pattern:

https://github.com/run-llama/cloud_llama_deploy/blob/main/packages/llamactl/src/llama_deploy/cli/config/_migrations.py

assert "Event data is required" in response.text


@pytest.mark.asyncio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we need a test for querying?

@zhaotai
Copy link
Contributor

zhaotai commented Oct 17, 2025

Maybe this question looks dumb, but why do we need to allow metadata to be arbitrary JSON?
Could you help me understand the thinking behind this design?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants