fix(compiler): thread actor-level system_prompt into graph node metadata #7
No reviewers
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#6 compile_actor() drops graph-level system_prompt — not threaded into CompiledActor
cleveragents/cleveractors-core
Reference
cleveragents/cleveractors-core!7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/compiler-thread-system-prompt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
compile_actor()silently dropped the actor-levelsystem_promptfield fortype: graphactors. TheCompiledActorcontained no trace of it, forcing host applications to keep the rawActorConfigSchemain scope as a workaround.This fix applies three targeted additions across two files to close both the compilation gap and the runtime context gap.
Motivation
docs/reference/actors_schema.mdexplicitly documentssystem_promptas "Default prompt for graph-level agents" — placing it in the same semantic category asproviderandmodel: actor-level fields that serve as fallback defaults for all AGENT nodes. The compiler already threadedproviderandmodelviasetdefault;system_promptwas simply never added to the same pattern.A second independent gap in
Node._execute_agent()meant that even after fixing the compiler, thesystem_promptvalue would not appear in the context dict passed toagent.process_message().Changes
src/cleveractors/actor/compiler.py_map_node()gains anactor_system_prompt: str | None = Noneparameter.merged_meta.setdefault("system_prompt", actor_system_prompt)is applied inside theif node.type == NodeType.AGENT:block, after the existingprovider/modelcalls.setdefaultpreserves any per-node override inconfig.system_prompt.actor_system_prompt is not None, so actors without a top-levelsystem_promptdon't carry a"system_prompt": Noneentry in every AGENT node's metadata.compile_actor()passesactor_system_prompt=config.system_promptto_map_node().src/cleveractors/langgraph/nodes.pyNode._execute_agent()extractsnode_system_promptfromself.config.metadata.get("system_prompt")and injects it into the context dict beforestate.metadatais merged. This allows host agents to readcontext.get("system_prompt")without a direct reference to the rawActorConfigSchema. Per-executionstate.metadata["system_prompt"]overrides still take precedence.isinstance(raw, str)guard rejects non-string values (e.g. integer, list) that could be injected via manually constructedNodeConfig."system_prompt"is added toignore_keysto prevent agents from mutating it in the context dict and accidentally persisting the mutation intometadata_updates.docs/reference/actor_compiler.mdAGENTrow now references a detailed "AGENT node defaults" subsection describing thesystem_promptthreading behavior.features/compiler_system_prompt.feature+features/steps/compiler_system_prompt_steps.pyTen BDD scenarios covering the full behavioral surface:
system_promptis threaded into each AGENT node'sNodeConfig.metadata.config.system_prompttakes precedence over the actor-level default (setdefault semantics).agent.process_message()receivessystem_promptin its context dict.state.metadata["system_prompt"]overrides the compiled default at runtime.state.metadata["system_prompt"] = Noneoverrides a compiled default (clearing the prompt).system_promptis threaded into AGENT node metadata.system_promptis passed into the runtime context dict.system_promptin compiled metadata.system_promptdoes not add the key to AGENT node metadata (post-review: was "set to None").system_promptis excluded from the runtime context dict.Post-review additions
Step-definition file reorganized into functional sections (compilation assertions, runtime assertions). "Each AGENT node" step definitions include a guard against zero-AGENT-node graphs.
Quality Gates
nox -s lintnox -s typechecknox -s unit_testsnox -s coverage_reportnox -s security_scannox -s dead_codenox -s complexityCloses #6
f4155e489da18e8c5931a18e8c5931bc01753113bc017531135aeadcc0aa5aeadcc0aa61c8a6f48f61c8a6f48fdd6c20df5dSelf-QA Review — Approved ✅
Ran 2 review/fix cycles. The PR is ready to merge.
Cycle 1 — Request Changes (0C / 3M / 5m / 2n)
All issues were addressed in the same cycle:
system_prompt(compiler + runtime)state.metadata = {"system_prompt": None}runtime overridesetdefault(None)unconditionally polluted AGENT node metadata shapeif actor_system_prompt is not None:metadata.get()returnedAny; no runtime type guardisinstance(node_system_prompt, str)system_promptabsent fromignore_keys— agent mutations leaked to state"system_prompt"toignore_keys# Then steps for new scenarioswas a drafting artifactagent_nodes_found > 0guard addedAfter fixes: 17/17 scenarios, all 7 quality gates ✅
Cycle 2 — Approve (0C / 0M / 3m / 3n)
No further fixes applied. Remaining items are non-blocking:
system_promptin node metadataignore_keysexclusion workssystem_promptoverride combination_CapturingAgentuses shallowdict()copy instead ofdeepcopy"None"edge caseThese can be addressed in a follow-up ticket if desired.
Quality Gates (final)
nox -s lintnox -s typechecknox -s unit_testsnox -s coverage_reportnox -s security_scannox -s dead_codenox -s complexity