Skip to content

Python: [Bug] Missing ExecutorFailedEvent in workflow if an executor throws exception #2508

@a1exwang

Description

@a1exwang

Repro steps:

  1. Run main.py (attached below)
  2. I get output
<class 'agent_framework._workflows._events.WorkflowStartedEvent'>
<class 'agent_framework._workflows._events.WorkflowStatusEvent'>
<class 'agent_framework._workflows._events.WorkflowFailedEvent'>
<class 'agent_framework._workflows._events.WorkflowStatusEvent'>
Traceback
...

Expected results

The output contains ExecutorFailedEvent so I can know where the error roots from when there are multiple executors. But I see the ExecutorFailedEvent is already queued here, but I don't know why it is not propagate outside

with _framework_event_origin():
failure_event = ExecutorFailedEvent(self.id, WorkflowErrorDetails.from_exception(exc))
await context.add_event(failure_event)

References

main.py

import asyncio
from agent_framework import WorkflowBuilder, Executor, handler, ChatMessage, WorkflowContext

class WriterExecutor(Executor):
    def __init__(self, id: str = "Writer"):
        super().__init__(id=id)

    @handler
    async def handle(self, message: ChatMessage, ctx: WorkflowContext[list[ChatMessage]]) -> None:
        raise RuntimeError("Mock error")

writer_executor = WriterExecutor()
workflow = (
    WorkflowBuilder(
        name="test_workflow",
        description="test",
    )
    .set_start_executor(writer_executor)
    .build()
)


async def main():
    async for event in workflow.run_stream(ChatMessage(role="user", content="Test")):
        print(type(event))

if __name__ == "__main__":
    asyncio.run(main())

My package versions:

# uv pip freeze
agent-framework-core==1.0.0b251120
agent-framework-devui==1.0.0b251120
annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.11.0
attrs==25.4.0
azure-core==1.36.0
azure-identity==1.25.1
certifi==2025.11.12
cffi==2.0.0
charset-normalizer==3.4.4
click==8.3.1
colorama==0.4.6
cryptography==46.0.3
distro==1.9.0
fastapi==0.122.0
googleapis-common-protos==1.72.0
grpcio==1.76.0
h11==0.16.0
httpcore==1.0.9
httptools==0.7.1
httpx==0.28.1
httpx-sse==0.4.3
idna==3.11
importlib-metadata==8.7.0
jiter==0.12.0
jsonschema==4.25.1
jsonschema-specifications==2025.9.1
mcp==1.22.0
msal==1.34.0
msal-extensions==1.3.1
openai==2.8.1
opentelemetry-api==1.38.0
opentelemetry-exporter-otlp-proto-common==1.38.0
opentelemetry-exporter-otlp-proto-grpc==1.38.0
opentelemetry-proto==1.38.0
opentelemetry-sdk==1.38.0
opentelemetry-semantic-conventions==0.59b0
opentelemetry-semantic-conventions-ai==0.4.13
packaging==25.0
protobuf==6.33.1
pycparser==2.23
pydantic==2.12.5
pydantic-core==2.41.5
pydantic-settings==2.12.0
pyjwt==2.10.1
python-dotenv==1.2.1
python-multipart==0.0.20
pywin32==311
pyyaml==6.0.3
referencing==0.37.0
requests==2.32.5
rpds-py==0.29.0
sniffio==1.3.1
sse-starlette==3.0.3
starlette==0.50.0
tqdm==4.67.1
typing-extensions==4.15.0
typing-inspection==0.4.2
urllib3==2.5.0
uvicorn==0.38.0
watchfiles==1.1.1
websockets==15.0.1
zipp==3.23.0

Metadata

Metadata

Assignees

Labels

pythonworkflowsRelated to Workflows in agent-framework

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions