Workflow Library & Evaluation
The workflow library is a layer that enables Agent Tracer to function as a tool for "rediscovering good work practices". The core is not just storing evaluation notes, but creating Workflow Snapshot and Workflow Context from task timelines and leaving those results in a re-searchable form.
Core Files
packages/core/src/domain/types.tspackages/core/src/workflow/snapshot.tspackages/core/src/workflow/context.tspackages/server/src/application/monitor-service.tspackages/server/src/application/ports/evaluation-repository.tspackages/server/src/infrastructure/sqlite/sqlite-evaluation-repository.tspackages/server/src/presentation/controllers/evaluation.controller.tspackages/web/src/api.tspackages/web/src/components/TaskEvaluatePanel.tsxpackages/web/src/components/workflowPreview.tspackages/web/src/components/WorkflowLibraryPanel.tsx
Data Model
WorkflowEvaluationData
Common base for evaluation metadata.
useCaseworkflowTagsoutcomeNoteapproachNotereuseWhenwatchouts
ReusableTaskSnapshot
A reusable task summary. buildReusableTaskSnapshot() combines timeline events and evaluation data to create the fields below.
objectiveoriginalRequestoutcomeSummaryapproachSummaryreuseWhenwatchItemskeyDecisionsnextStepskeyFilesmodifiedFilesverificationSummarysearchText
TaskEvaluation / Stored Record
The basic evaluation type TaskEvaluation contains:
taskIdratingevaluatedAt- All fields from
WorkflowEvaluationData
Server stored record (StoredTaskEvaluation) adds:
workflowSnapshotworkflowContextsearchText
WorkflowSummary / WorkflowSearchResult / WorkflowContentRecord
WorkflowSummaryis a type for library listing.WorkflowSearchResultis a type for similar search results and includesworkflowContextmarkdown.WorkflowContentRecordis a type for full snapshot/context detailed view and includesworkflowSnapshot,workflowContext,searchText,source(saved|generated).
In other words, listings and search results are lightweight summary types, while full snapshot/context is queried via a separate content read path.
Workflow Snapshot Generation Rules
buildReusableTaskSnapshot() in packages/core/src/workflow/snapshot.ts is the source of truth for generation rules.
Inputs
objective: Usually task title or deriveddisplayTitleevents: Full task timelineevaluation: Optional input. All or part ofWorkflowEvaluationData
Field Generation Method
originalRequestbodyortitleof firstuser.messageeventoutcomeSummaryPriority:evaluation.outcomeNote, then lastassistant.response, else inferred from modified file count and verification summaryapproachSummaryPriority:evaluation.approachNote, else top 2 decision lines extracted from planning/implementation/coordination eventsreuseWhenevaluation.reuseWhenwatchItemsevaluation.watchoutsdecomposed by line/delimiter + failed verification/rule titleskeyDecisionsEvents from planning/implementation/coordination lanes converted to human-readable single-line descriptions, then deduplicatednextStepsIncomplete todo titles + not-yet-concluded question promptskeyFilesModified files +filePathsfrom event metadatamodifiedFilesFiles fromfile.changedevents withwriteCount > 0verificationSummaryChecks: X (Y pass, Z fail)summary based on verification/rule event countssearchTextSearch string created by combining objective, originalRequest, useCase, outcomeSummary, approachSummary, reuseWhen, tags, watchItems, keyDecisions, keyFiles
Workflow Context Generation Rules
buildWorkflowContext() in packages/core/src/workflow/context.ts is the source of truth for markdown assembly.
Generation order is:
# Workflow: <taskTitle>- Snapshot-based sections
## Plan- Per-lane sections
## Modified Files## Open TODOs## Verification Summary
Snapshot-based Sections
The following sections are included only when snapshot and evaluation have values:
## Original Request## Use Case## Outcome## What Worked## Reuse When## Key Decisions## Next Steps## Watchouts## Key Files## Verification Snapshot
Per-Lane Sections
Lanes currently included in workflow context are fixed in the following order:
ExplorationImplementationQuestionsTODOsBackgroundCoordination
planning is separated into its own ## Plan section, and the user lane is not re-included in lane summaries.
Also, context.saved, terminal.command, generic titles (action logged, tool used, etc.) prioritize detail over title to make the context markdown appear less verbose.
Generation and Storage Flow
Web
TaskEvaluatePanel receives a selected task timeline and operates in the following flow:
- Creates
WorkflowEvaluationDatafrom evaluation input. - Auto-generates snapshot with
buildReusableTaskSnapshot(). - Auto-generates context markdown with
buildWorkflowContext(). - User can modify snapshot and context via Preview/Edit fields/Regenerate.
- On save, sends evaluation metadata,
workflowSnapshot, andworkflowContexttoPOST /api/tasks/:id/evaluate.
workflowPreview.ts is a helper utility that converts snapshot draft to a string for textarea editing and parses it back to ReusableTaskSnapshot.
Server
MonitorService.upsertTaskEvaluation() saves by the following rules:
- Reads task and events.
- If
deriveTaskDisplayTitle()exists, uses it as workflow title instead of original title. - If request lacks
workflowSnapshot, server generates it. - If request lacks
workflowContextor is empty string, server generates it. - On save, records
searchTextbased onsnapshot.searchText.
Relationship Between Saved and Generated
SqliteEvaluationRepository.getWorkflowContent() prioritizes using stored snapshot/context if available. Otherwise returns re-generated value from current timeline. So WorkflowLibraryPanel detail view exposes source: "saved" | "generated" together.
Server Endpoints
POST /api/tasks/:id/evaluateGET /api/tasks/:id/evaluateGET /api/workflowsGET /api/workflows/similarGET /api/workflows/:id/content
/api/workflows/similar returns search results with workflowContext. Full snapshot/context detail is handled by /api/workflows/:id/content.
Web Features
TaskEvaluatePanel
- Evaluation metadata input
- Auto-generate snapshot/context
- Preview / Edit fields / Regenerate
- Final save
WorkflowLibraryPanel
- Query library listings
- Rating / text filter
- Detailed snapshot/context view of selected workflow
- Show if saved or generated
Current Risks
- Workflow content queries and similar search result hydration still involve read-heavy paths that re-read all events.
- Lexical search is sensitive to quality of
title,useCase,workflowTags,outcomeNote,approachNote,reuseWhen,watchouts,searchText. - Semantic ranking is only enabled when embedding service is available; fails over safely to lexical search.
- Generation quality is directly affected by timeline title/body/metadata quality.