Skip to content

mhavey/pm-for-agents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tmls2026 — Process Mining over Agent Traces

A research project: build agents on AWS Bedrock AgentCore, then analyze their execution behavior using process mining algorithms.

The hypothesis is that ReAct-style agents — which choose tools and order actions on the fly — produce execution traces that can be mined like a business process. Discovery algorithms (Heuristics, Inductive Miner) can reveal the agent's actual behavior; conformance checking can compare it to a designed playbook; performance analysis can find slow tools and bottleneck transitions.

The following diagram, from Toronto Machine Learning Summit 2026 talk, summarizes the approach at a high-level.

Architecture

  • The end-user through a chat UI makes a request to the agent. (Rather than an end user, the client may also be another agent or an application.)

  • The agent uses a set of tools to respond to the request. It uses an LLM model to decide which tools to use and when. The diagram shows AWS services: AgentCore for agent runtime, Bedrock for LLM.

  • The agent's orchestration of these tools follows an intended business process flow.

  • Besides being tasked with responding correctly, the agent must also be observable! We enable OpenTelemetry for the agent to publish a trace of what it's doing.

    • Evals: We can do LLM-as-a-judge to measure how well the agent responded: correctness of response, helpfulness of response, correct tool choice, and other measures.
    • Metrics: Through CloudWatch, we can measure agent performance with metrics like CPU, memory, token usage, and others. (These do not require telemetry.)
    • Traces: Raw XRay traces can be views in CloudWatch, enabling us to see step-by-step how the agent processed the request. Additionally, the traces give us an event log from which to do process mining on the agemt. This repo provides a conversion tool that transforms XRay to eXtensible Event Stream (XES). It also provides notebooks to run process mining analysis on the event logs using Process Mining For Python (pm4py).

    The TMLS talk elaborates the agent-process connection, making the case for BPM skill both in imagining the intended process flow in terms of traditional workflow patterns and observing the flow with process mining.

Repository Layout & Core Agents

agents/
  research_react/           # Strands ReAct agent for arXiv article research
  market_intel_graph/       # Strands explicit graph agent for market intel research
  trusteeship/              # Trusteeship-application agent, uses Strands ReAct
notebooks/                  # Jupyter notebooks for data prep and process mining
  • market_intel_graph (Explicit Graph Orchestration)

    • Orchestration: Built using a graph-based routing pattern structured around an intended business process. It utilizes an explicit workflow model mapped out in intended_flow.bpmn to govern transitions between tasks.
    • Behavior: This agent specializes in market intelligence gathering. It systematicallyg executes structured steps to gather, filter, and synthesize competitive intelligence data. It is packaged for containerized deployment via a local Dockerfile and build.sh script.
    • Trace Signature: Highly structured and deterministic. Because execution paths closely track a predefined BPMN diagram, its trace signature provides an ideal baseline for identifying bottleneck transitions and analyzing step performance rather than routing variance.
  • research_react (Dynamic ReAct Loop)

    • Orchestration: Employs a single agent loop executing dynamically based on a comprehensive system_prompt.md config file.
    • Behavior: Unlike the hardcoded paths of a graph agent, this LLM dynamically chooses its path at runtime. For any given research task, it evaluates context on the fly to decide whether it needs to fetch information, pivot to an external web search, halt for a deep-dive analysis confirmation, or conclude the loop by answering the user directly.
    • Trace Signature: Highly variable execution depth and unpredictable step sequences. It is bounded loosely by a behavioral reference model (intended_flow.bpmn), making its runtime traces the primary target in this project for advanced conformance checking and alignment analysis.
  • trusteeship (Procedural Application Workflow)

    • Orchestration: A domain-specific agent tailored to manage the rigorous, end-to-end administration of court-appointed trusteeship applications.
    • Behavior: Operates with tight legal guardrails to navigate user discovery. It systematically walks users through gathering required assets, reviews documentation readiness, evaluates eligibility constraints against standard legal criteria, and ensures administrative validation before outputs are prepared for final court inventory submission.
    • Trace Signature: Form-driven, sequential, and highly dependent on step prerequisites. Its logs are optimized for verifying procedural compliance, detecting skipped steps, and catching data-dependency violations.

Analytics Notebooks (/notebooks)

A collection of notebooks to test agents, prepare agent traces for process mining, and run process mining analysis using Process Mining for Python (pm4py).

  • TalkToAgent.ipynb: Provides an interactive interface to execute test queries against deployed agents and generate live traces.
  • PreparePMLogs.ipynb: Convert XRay agent traces to XES event logs for pm4py.
  • PMAnalysis-ResearchAgent.ipynb: Process mining analysis for the React-based research agent.
  • PMAnalysis-MarketIntel.ipynb: Process mining analysis of the graph-based market intel agent.
  • PMAnalysis-Trusteeship.ipynb: Process mining analysis of the long-lived React-based trusteeship agent.
  • InstallPM4Py.ipynb: A quick-start notebook for verifying the environment and dependencies for process mining execution.

See notebooks/README.md for a high-level notebook workflow, execution order, and how the agent traces are transformed into XES logs.

Setup

See SETUP.md.

Running Agents and Mining

After setup, use the notebooks to run the agents, convert their traces to XES, and run process mining analysis.

Open Jupyter Labs

Open the AWS console for your account and select the correct region. From the SageMaker AI console, locate the notebook instance and select Open Jupyter Labs.

Open notebook instance

Clone this repo to get notebooks

In Jupyter Lab, open a terminal.

Open terminal

In terminal, clone the agent:

cd SageMaker
git clone https://github.com/mhavey/pm-for-agents.git

In the left panel, navigate to pm-for-agents/notebooks.

List notebooks

Talk to the Agents (if you deployed one or more agents)

Open TalkToAgent.ipynb. Move through the cells and follow instructions.

A key setup step is to obtain the ARNs for each agent you wish to talk to. You can either hard-code the agent ARN or have the notebook discover them. Refer to Find Agent ARNS section.

Once ARNS are defined, use the cells to talk to the agent with your own prompts or the sample ones provided. Use cells under Test Harness to run a series of tests to generate a good sample of traces for process mining analysis.

Observe Traces in CloudWatch (if you deployed one or more agents)

Assuming you ran tests in TalkToAgent.ipynb, view XRay traces in the AWS Console. Navigate to the CloudWatch console and select GenAI Observability | Bedrock AgentCore from the left menu. View the traces for your agent.

Traces

Select a trace from the list to see each step of the trace.

Trace

Convert Traces to XES (if you deployed one or more agents)

Back in Jupyter Labs, open PreparePMLogs.ipynb and walk through the cells to convert the XRay logs to XES.

Skip this if you did not deploy agents.

You may also skip if you prefer to use the pregenerated XES files in the xeslogs folder.

Mine!

Each of the three agents has a notebook in which to run process mining analysis.

If you did not deploy agents, you can still run these using the pregenerated XES files in the xeslogs folder.

First install pm4py by opening InstallPM4Py.ibynb. Run through the steps to install.

Then mine by trying the analysis notebooks PMAnalysis_MarketIntel.ipynb, PMAnalysis_ResearchAgent.ipynb, and PMAnalysis_Trusteeship.ipynb

Further Reading

License and Copyright

Copyright (c) 2026 Michael Havey. All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors