Commit Graph

71 Commits

Author SHA1 Message Date
llama-org-ci-bot[bot] a720c9a4de chore: version packages (#370) 2026-02-13 15:54:24 -06:00
Logan 359091361f fix span handling and span hierarchy propagation (#381) 2026-02-13 15:41:09 -06:00
Adrian Lyjak 7433d4cddb Add fix for double send when waiter event and accepted event match (#351) 2026-02-09 18:40:40 -05:00
llama-org-ci-bot[bot] fa804b6dcf chore: version packages (#338)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-02-06 14:46:20 -05:00
Adrian Lyjak 6ece7970dd Fix concurrent step cancellation regression in 2.14.0 (#340)
* Add xfailing test for concurrent step cancellation regression in 2.14.0

This test exposes a regression introduced in 2.14.0:
- In 2.13.1: A single asyncio.sleep(0) yield after stop_step returns is
  sufficient for cancellation to propagate, blocking other_step's write.
- In 2.14.0: The yield is not enough - other_step's write still goes through.

Test sequence:
1. stop_step returns StopEvent
2. Single yield point (asyncio.sleep(0))
3. other_step writes to stream

In 2.13.1: write is blocked (PASS)
In 2.14.0: write goes through (FAIL)

The architectural change from asyncio.Queue to tick_buffer + wait_for_next_task
in commit 45e7614 ("Remove asyncio queue from control_loop #315") changed the
timing characteristics, requiring longer delays for cancellation to take effect.

In 2.13.1, workers immediately put ticks in the queue via queue_tick(), and
the continuous _pull() task meant quick processing. In 2.14.0, workers return
results collected by wait_for_next_task, adding overhead that delays cancellation.

Related: https://llama-index.slack.com/archives/C0A3TFERFHV/p1770391664693399

https://claude.ai/code/session_01VWUvDsJ88uaVn4jT68Ny8X

* Fix concurrent step cancellation regression in 2.14.0

When a worker returns a StopEvent, immediately cancel other running
workers before adding the tick to the buffer. This restores the 2.13.1
behavior where a single asyncio.sleep(0) yield after stop_step returns
is sufficient for cancellation to propagate.

The regression was introduced in commit 45e7614 ("Remove asyncio queue
from control_loop #315") which changed the architecture from asyncio.Queue
to tick_buffer + wait_for_next_task. The new architecture had more overhead,
causing cancellation to take longer.

The fix checks if the completed worker's result contains a StopEvent, and
if so, calls cleanup_tasks() immediately to cancel other workers before
they can write to the event stream.

Also removes internal implementation references from comments.

Fixes: https://llama-index.slack.com/archives/C0A3TFERFHV/p1770391664693399

https://claude.ai/code/session_01VWUvDsJ88uaVn4jT68Ny8X

* Add patch changeset for concurrent step cancellation fix

* fix lint

* Improve StopEvent cancellation speed for sibling steps

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-06 14:41:46 -05:00
Adrian Lyjak ef7f808c70 Fix OpenAPI schema version to use correct package name (#337) 2026-02-06 01:38:44 -05:00
Adrian Lyjak e9c1fa4467 Fix openapi generation script to use correct module path (#335)
* Fix openapi generation script to use correct module path

The hatch script `server:openapi` was invoking `python -m workflows.server.server`,
but `workflows.server` is just a re-export shim with no `server.py` submodule.
The actual module with the `__main__` block lives at `llama_agents.server.server`.

* Move OpenAPI generation from workflows package to server package

The hatch openapi script and CI workflow were configured in the
llama-index-workflows package, which required a special hatch environment
with the `server` extra to access the server module. Since the actual
server code lives in llama-agents-server, move everything there where
all dependencies are already available directly.

- Add hatch config and openapi script to llama-agents-server pyproject.toml
- Remove hatch config and hatch dev dep from llama-index-workflows pyproject.toml
- Update publish_openapi.yml to run from packages/llama-agents-server
2026-02-05 16:02:36 -05:00
llama-org-ci-bot[bot] 5d48601ed7 chore: version packages (#334) 2026-02-05 15:15:16 -05:00
Adrian Lyjak 808cddc4a3 refactor(server): Split up server.py and add service (#326)
* refactor(server): Split up server.py and add service
2026-02-04 15:23:04 -05:00
Adrian Lyjak 45e7614554 Remove asyncio queue from control_loop (#315) 2026-02-03 12:50:10 -05:00
Adrian Lyjak 0d8f5a7b27 fix: improve dev CLI pytest robustness (#320) 2026-02-02 19:02:44 -05:00
Adrian Lyjak 10d619a551 rename llama-index-workflows-* -> llama-agents-* (#319)
* rename llama-index-workflows-client -> llama-agents-client

* integration tests too
2026-02-02 16:40:17 -05:00
Adrian Lyjak 5ded4b40fa chore: CI/testing improvements for parallel test execution (#317)
* chore: CI/testing improvements for parallel test execution

- Add workflows-dev pytest command with parallel test runner
- Add pytest-xdist for parallel test execution (-nauto)
- Add timeouts to prevent test hangs (--timeout=10/60/120)
- Use module-scoped async fixtures for faster tests
- Remove mypy in favor of basedpyright/ty type checking
- Add test-docker CI job for integration tests with testcontainers
- Exclude integration tests from Python 3.9/3.14 in CI matrix
2026-02-02 13:27:10 -05:00
Adrian Lyjak 73c12541f5 refact: introduce runtime plugin architecture and context separation (#296)
* refact: introduce runtime plugin architecture and context separation

- Add Runtime abstract base class with BasicRuntime as default implementation
- Split context into external, internal, and pre-context modules
- Replace workflow_registry with workflow_tracker for workflow lifecycle management
- Remove broker.py in favor of runtime-managed execution
- Add plugins package with get_current_runtime() for context-aware runtime access
- Update handler and workflow to use new runtime interfaces
2026-01-31 18:19:42 -05:00
Adrian Lyjak 33bbd2398b Read workflows from globals rather than sys modules, (#314)
* Read workflows from globals rather than sys modules, to avoid module conflicts
2026-01-30 14:44:50 -05:00
Adrian Lyjak db90f89b74 Separate server/client, and move to llama_agents namespace (#277)
* prep packages

* wrong coverage detection I think

* add ts deps?

* extend path for namespaces

* the big move, import issues though

* llama_index.workflows

* llama_agents

* alias may be working

* add type checker ignores for workflows secondary namespace, update ty, and add re-exports

* Add descriptions to new client and server packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Rather, commit the outputs

* keep the py files separate

* ignore examples deps

* Create afraid-books-own.md

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:16:02 -05:00
Adrian Lyjak 2d5974de0c Add agent builder docs, add resource config docs, re-organize wf docs with more explicit cloud docs section (#305) 2026-01-28 12:45:04 -05:00
hippopond 0e826b111b Draw nested workflows (#292) 2026-01-27 18:16:29 +00:00
llama-org-ci-bot[bot] 3a2336356d chore: update debugger assets (#309)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-27 07:26:45 -05:00
Adrian Lyjak 2900f58f69 Support state type inheritance in workflows (#301) 2026-01-26 12:23:36 -05:00
llama-org-ci-bot[bot] 5716b1ec7f chore: version packages (#304)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-25 09:51:24 -05:00
Adrian Lyjak e958ed28db fix: ResourceConfig was loading config file eagerly (#306) 2026-01-25 09:43:38 -05:00
Adrian Lyjak ebaf212bbe Add resource validation to workflow.validate() (#303)
* feat: Add resource and resource config validation to workflow validate()

Adds optional resource validation to validate():

- validate_resource_configs (default True): Validates config files exist
  and match their Pydantic schemas
- validate_resources (default False): Resolves resource factories, also
  catches circular dependencies via ResourceManager

Key implementation:
- _validate_resource_configs(): Stack-based traversal of all resources
  and their dependencies, validates _ResourceConfig instances
- _validate_resources(): Resolves resources via ResourceManager.get()
- validate() now runs even with disable_validation=True when called
  explicitly
- Python 3.9 compat: restore event loop after asyncio.run()

* Create smooth-donkeys-run.md

* Update test_resources.py

Kill off a silly extra test

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-23 19:49:22 -05:00
llama-org-ci-bot[bot] e6bb9ec67b chore: version packages (#302)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-23 16:55:31 -05:00
Adrian Lyjak 6dd7fc0de8 Add resource config node support to workflow representation (#294) 2026-01-23 16:14:30 -05:00
Adrian Lyjak be198692de feat: Make resource dependencies more flexible (#295) 2026-01-23 12:41:37 -05:00
Adrian Lyjak 9910929b82 add llama_index integration tests (#293)
* chore: add llama_index to gitignore

Added cloned reference repository llama_index/ to gitignore to avoid
tracking the large external repository.

* feat: add llama-index-integration-tests package

Add a new internal (not published) package for running integration tests
against llama-index-core workflow abstractions. This ensures that updates
to the workflows package don't break the agent classes in llama-index-core.

Includes tests for:
- FunctionAgent: basic execution, tools, max iterations, context handling
- ReActAgent: basic execution, retry on parse errors, memory persistence
- AgentWorkflow: multi-agent execution, handoff, memory, event streaming

Uses a custom MockFunctionCallingLLM to mock LLM responses without external
dependencies, ensuring tests run reliably.

* refactor: use llama-index-core MockFunctionCallingLLM

- Update llama-index-core dependency to >= 0.14.13
- Remove custom mock_llm.py, use built-in MockFunctionCallingLLM
- Enable test_early_stopping_method_generate (no longer needs skip)

All 12 integration tests now pass.

* fix: improve integration tests package

- Update basedpyright config to Python 3.13
- Fix ruff format/check issues (sorted imports, removed unused imports)
- Remove unused conftest.py fixture
- Add workflow feature tests:
  - wait_for_event inside tool functions (HITL pattern)
  - Context state management via ctx.store
  - Pickle serialization for workflow pause/resume
  - Multiple sequential tool calls with shared state

All 16 tests pass.

* refactor: reorganize integration tests by workflow feature

- Organize tests by workflow capability rather than agent type:
  - test_context_store.py: ctx.store.get/set operations
  - test_event_streaming.py: stream_events() and event types
  - test_human_in_the_loop.py: wait_for_event, serialization
  - test_error_handling.py: max_iterations, early stopping

- Add pytest parameterization for FunctionAgent vs ReActAgent where applicable
  (non-tool tests use both; tool-based tests use FunctionAgent only since
  it uses function calling format)

- Move helper functions to src/llama_index_integration_tests/helpers.py
  to avoid conftest.py import issues

- Remove tests/__init__.py to fix mypy duplicate module error

- Add type: ignore comments for Event dynamic fields

* fix ci

* better types

* type fixes/ignores

* Update packages/llama-index-integration-tests/src/llama_index_integration_tests/helpers.py

Co-authored-by: Clelia (Astra) Bertelli <133636879+AstraBert@users.noreply.github.com>

* fix

* add to ci

* 3.9 compat

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Clelia (Astra) Bertelli <133636879+AstraBert@users.noreply.github.com>
2026-01-23 09:54:22 -05:00
Adrian Lyjak 9a92670315 feat: run uv sync after version bumping in changeset-version command (#286)
Modified sync_package_version_with_pyproject to return a boolean indicating
whether the pyproject.toml was changed. After syncing all packages, if any
pyproject.toml was updated, run uv sync in the root directory to update
the lock file.
2026-01-16 17:09:50 -05:00
llama-org-ci-bot[bot] aaa2e19fce chore: version packages (#284)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-15 15:29:56 -05:00
OS-ramamurtisubramanian 85f948e504 fix: rebuild_state_from_ticks clears in_progress before replaying (#282) 2026-01-15 20:24:40 +00:00
Adrian Lyjak bfbfba4780 Fix collect_events returning None instead of empty list for empty expected list (#283) 2026-01-15 20:24:15 +00:00
llama-org-ci-bot[bot] a15969bdf9 chore: version packages (#279)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-14 10:16:52 -05:00
Adrian Lyjak 40be1c7f6f Adds workflow name to workflow graph (#278)
* feat: add workflow class name to WorkflowGraph representation

Add a required `name` field to the WorkflowGraph model that contains
the workflow class name. This provides better identification of workflows
when viewing their graph representation or JSON output.
2026-01-14 06:19:24 +00:00
llama-org-ci-bot[bot] 192437fc47 chore: version packages (#272)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-13 16:12:59 -05:00
Adrian Lyjak 0d72b4ded0 refact: split out workflow representations, to prep for separate server package (#274) 2026-01-13 13:26:54 -05:00
Clelia (Astra) Bertelli 7a85c96d68 feat: Add file config resource abastraction (#271) 2026-01-12 16:53:00 -05:00
Adrian Lyjak 2ff316d0c9 drop and restore idle workflows in workflow server (#266) 2026-01-12 16:52:22 -05:00
Adrian Lyjak f96faa2d03 feat: add dedicated StopEvent subclasses for workflow termination scenarios (#264)
* feat: add dedicated StopEvent subclasses for workflow termination scenarios

Add WorkflowTerminationEvent base class and specific subclasses to provide
detailed information when workflows end abnormally:

- WorkflowTimedOutEvent: Published when workflow exceeds timeout, includes
  timeout duration and list of active steps
- WorkflowCancelledEvent: Published when workflow is cancelled by user
- WorkflowFailedEvent: Published when a step fails permanently, includes
  step name, exception type, and exception message

These events replace the empty StopEvent() instances that were previously
published, allowing consumers to understand why a workflow ended and take
appropriate action.

Closes: issue about providing exception information in StopEvent

* refactor: simplify termination events to inherit directly from StopEvent

* chore: add changeset

* feat: add traceback and fully qualified exception type to WorkflowFailedEvent

* feat: add retry info (attempts, elapsed_seconds) to WorkflowFailedEvent

Also fixes a bug where step_function.py used time.monotonic() instead of
time.time(), causing incompatible timestamps with first_attempt_at.

* fix lints/locks

* docs: add workflow termination events to streaming docs

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-10 13:03:49 -05:00
Adrian Lyjak e53c654b42 Add resource nodes to workflow graph export (#269)
* feat: add resource nodes to workflow graph export

Add support for visualizing resource dependencies in workflow graphs:

- Enhanced _Resource class with source location metadata (file, line,
  docstring, unique hash for deduplication)
- Added ResourceDefinition.type_annotation to capture the type from
  Annotated[T, Resource(...)]
- Added WorkflowGraphResourceNode protocol model with full metadata
- Added DrawWorkflowResourceNode class for intermediate representation
- Updated DrawWorkflowEdge to support edge labels (variable names)
- Modified extract_workflow_structure to extract and deduplicate
  resource nodes, connecting them to steps with labeled edges
- Updated Pyvis and Mermaid renderers to display resource nodes
  (hexagon shape, plum color) with metadata tooltips

* test: add tests and example for resource nodes visualization

- Add tests for resource node extraction in test_representation_utils.py
- Add tests for resource rendering in test_drawing.py (Mermaid + Pyvis)
- Add workflow_with_resources fixture with multiple resources
- Add runnable example (examples/visualization/resource_nodes_example.py)
  that generates both Mermaid and Pyvis output with resource nodes

* chore: add changeset for resource nodes feature

* fix: reverse resource edge direction to step -> resource

* refactor: unify DrawWorkflowNode and DrawWorkflowResourceNode

- Merge resource-specific fields into DrawWorkflowNode
- Add to_resource_response_model() for resource serialization
- Keep DrawWorkflowResourceNode as backwards compat alias
- Simplify type annotations in rendering code (remove unions)
- Remove isinstance checks since all nodes are now DrawWorkflowNode

* refactor: simplify _get_clean_node_id to use node_type prefix

* refactor: merge resource_nodes into nodes list

Unify resource nodes with the main nodes list instead of a separate
resource_nodes field. This simplifies the API and rendering code while
maintaining backwards compatibility through a property accessor.

- Remove resource_nodes field from DrawWorkflowGraph
- Add resource_nodes property for backwards compatibility
- Merge WorkflowGraphResourceNode fields into WorkflowGraphNode
- Simplify rendering loops to single iteration over nodes

* refactor: remove unnecessary backwards compatibility aliases

This is all new code in this PR - no need for backwards compat aliases.
Removes WorkflowGraphResourceNode, DrawWorkflowResourceNode,
to_resource_response_model, and resource_nodes property.

* perf: make resource metadata extraction lazy

Move expensive inspect operations (getfile, getsourcelines, getdoc)
and hash computation from Resource creation time to graph extraction
time. This avoids the overhead when resources are used at runtime
but visualization is not needed.

* test: remove unnecessary async from mermaid drawing tests

* consolidate types

* Split types

* feat: add description and schema fields to workflow graph nodes

- Add description field to WorkflowGraph (workflow class docstring)
- Add description field to WorkflowStepNode (step function docstring)
- Add event_schema field to WorkflowEventNode (Pydantic JSON schema)
- Rename WorkflowResourceNode.docstring to description for consistency
- Rename WorkflowGraphNodeEdges to WorkflowGraph

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* filter by node type

* Update add_resource_nodes.md

* remove resource hash

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-10 13:01:12 -05:00
Adrian Lyjak 3b043b8801 Add idle workflow tracking via internal event (#261) 2026-01-09 15:07:53 -05:00
llama-org-ci-bot[bot] 894445a355 chore: version packages (#268)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-09 15:04:13 -05:00
hippopond 96fd9c9bfb Add draw_most_recent_execution_mermaid (#265)
* feat: Add draw_most_recent_execution_mermaid function

Co-authored-by: cecli (gemini/gemini-2.5-pro)

* Draw Mermaid: Refactored code.  Not finished.

Draw Mermaid: More refactor

Draw Mermaid: More Refactor to clean up

Draw Mermaid: More refactor.

Draw Mermaid: Nicely Refactored

* Added mermaid code for draw_most_recent_execution_mermaid and test

test: Add tests for draw_most_recent_execution

Co-authored-by: cecli (gemini/gemini-2.5-pro)

Draw Mermaid: Added in the test case for draw_recent_execution_mermaid

* test case for draw_most_recent_execution_mermaid

* Moved import json to the top

* moved import json from second line to first line

* fix sort and bump lock

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Adrian Lyjak <adrianlyjak@gmail.com>
2026-01-07 21:41:33 +00:00
llama-org-ci-bot[bot] 1544647770 chore: version packages (#258)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-06 16:56:05 -05:00
llama-org-ci-bot[bot] f58537a6e6 chore: update debugger assets (#259)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2026-01-06 21:53:21 +00:00
Adrian Lyjak 013c3c278a chore: bump date on copyright (#262) 2026-01-06 14:44:32 -06:00
llama-org-ci-bot[bot] 6c35e4dace chore: update debugger assets (#256)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2025-12-29 20:02:50 -05:00
llama-org-ci-bot[bot] fde2ce064f chore: version packages (#253)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2025-12-24 10:55:20 -05:00
Adrian Lyjak 72160b1bb3 Refactor: Clarify Context.wait_for_event behavior (#243)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-12-24 10:53:29 -05:00
llama-org-ci-bot[bot] f8fa366063 chore: update debugger assets (#245)
Co-authored-by: llama-org-ci-bot[bot] <231146559+llama-org-ci-bot[bot]@users.noreply.github.com>
2025-12-24 10:51:34 -05:00
Roaim 94fa8cecaf fix(workflows): enforce retry delay and attempt limit (#252) 2025-12-24 10:50:28 -05:00