os:DoWork
Delegate complex, multi-step work to a general-purpose agent.
Subject: Class (optional)
Payload: genai:AgentPayload
Result: Resource
Handler: genai:AgenticHandler
Performs complex tasks that require planning, discovery, and multi-step execution across one or more domains, returning typed results.
Use os:DoWork when:
- The task requires iterative reasoning, discovery, and multiple action invocations
- You need to combine capabilities across domains that aren't available in a single query
- The work is too complex for a deterministic script but produces well-typed results
Do NOT use os:DoWork when:
- A deterministic query or single action can accomplish the goal
- os:Find is sufficient (simple resource lookup by class and criteria)
- The same goal was already delegated by a parent workflow (causes infinite loops)
os:DoWork takes a target result class as SUBJECT and a natural language goal in the payload.
It discovers relevant schemas and actions, plans an execution strategy, and iteratively
executes until the goal is met. Results are returned as typed resources matching the subject class.
IMPORTANT - The sub-agent starts with only the target class schema and bootstrap context. Include sufficient context in genai:prompt for it to understand the problem domain:
- Name relevant classes, properties, or relationships it will need to discover
- Describe constraints, criteria, and expected relationships between entities
- Mention specific data sources or domains if known
CRITICAL - genai:prompt must contain ONLY the actual goal and context:
- Strip meta-instructions like "use the agent", "delegate this"
- These cause infinite loops
# Reconcile financial statements, then look up the assigned auditor for each
CONSTRUCT {
?statement fin:status "reconciled" ;
fin:reconciledBy ?auditor .
}
WHERE {
?statement os:DoWork (fin:Statement [
genai:prompt "reconcile Q4 financial statements against bank records. Match fin:Transaction entries against bank:Statement line items by date and amount. Flag discrepancies as fin:Discrepancy resources."
]) .
?statement fin:assignedAuditor ?auditor .
}
# Identify at-risk projects, then collect their blockers into a list
CONSTRUCT {
?project proj:atRisk true ;
proj:blockerList ?blockers .
}
WHERE {
?project os:DoWork (proj:Project [
genai:prompt "identify projects at risk of missing Q1 deadline. Check proj:milestone dates against proj:schedule, look for unresolved proj:Blocker resources, and assess resource allocation via team:Assignment."
]) .
?project proj:blockers ?blocker .
BIND(os:collect(?blocker) AS ?blockers)
}