UAT: ActorConfigSchema missing global_context field — Jinja2 template context from actor YAML is silently dropped #2477

Open
opened 2026-04-03 18:36:49 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/actor-config-schema-global-context
  • Commit Message: fix(actor): add global_context field to ActorConfigSchema and wire to Jinja2 template engine
  • Milestone: v3.2.0
  • Parent Epic: #392

Description

The spec (docs/specification.md, lines 20178 and 20835) states:

The global_context top-level key in the actor configuration file populates this dictionary at load time. At runtime, the actor invocation context, plan context, and session context are merged with the following precedence: runtime context > plan context > session context > global_context from YAML.

The spec also lists global_context as a top-level key in actor YAML files:

| global_context | object | No | Key-value pairs accessible to all actors via {{ context.key }}. |

However, the v3 ActorConfigSchema in src/cleveragents/actor/schema.py does not have a global_context field. Since Pydantic's default extra behaviour is "ignore", any global_context key in an actor YAML file is silently discarded when the YAML is loaded via ActorConfigSchema.from_yaml_file().

The YAMLTemplateEngine._create_render_context() method (in src/cleveragents/actor/yaml_template_engine.py) does handle a context key, but there is no mechanism to extract global_context from the parsed ActorConfigSchema and pass it to the template engine.

Expected behaviour: ActorConfigSchema should include a global_context: dict[str, Any] field (defaulting to {}), and the actor loading pipeline should pass this to the Jinja2 template engine so that {{ context.key }} references in actor YAML templates resolve correctly.

Actual behaviour: global_context values in actor YAML files are silently dropped. Any {{ context.key }} references in actor YAML templates will resolve to empty strings or cause template errors.

Affected code locations:

  • src/cleveragents/actor/schema.pyActorConfigSchema class (missing global_context field)
  • src/cleveragents/actor/yaml_template_engine.py_create_render_context() method
  • docs/specification.md lines 20178, 20835

Subtasks

  • Write a failing Behave scenario that loads an actor YAML with a global_context block and asserts that {{ context.key }} resolves correctly (TDD — commit failing test first)
  • Add global_context: dict[str, Any] field (default {}) to ActorConfigSchema in src/cleveragents/actor/schema.py
  • Update YAMLTemplateEngine._create_render_context() in src/cleveragents/actor/yaml_template_engine.py to merge global_context from the parsed schema into the Jinja2 render context
  • Ensure context merge precedence matches the spec: runtime context > plan context > session context > global_context
  • Verify Pyright passes with strict typing (nox -e typecheck)
  • Ensure all nox stages pass (nox)
  • Update or add docstrings for modified classes/methods

Definition of Done

  • Failing Behave scenario committed and merged to master before fix is implemented
  • ActorConfigSchema has a global_context: dict[str, Any] field defaulting to {}
  • YAMLTemplateEngine._create_render_context() correctly merges global_context into the Jinja2 context with correct precedence
  • All Behave unit tests pass (nox -e unit_tests)
  • All Robot Framework integration tests pass (nox -e integration_tests)
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/actor-config-schema-global-context` - **Commit Message**: `fix(actor): add global_context field to ActorConfigSchema and wire to Jinja2 template engine` - **Milestone**: v3.2.0 - **Parent Epic**: #392 ## Description The spec (`docs/specification.md`, lines 20178 and 20835) states: > The `global_context` top-level key in the actor configuration file populates this dictionary at load time. At runtime, the actor invocation context, plan context, and session context are merged with the following precedence: runtime context > plan context > session context > global_context from YAML. The spec also lists `global_context` as a top-level key in actor YAML files: > | `global_context` | object | No | Key-value pairs accessible to all actors via `{{ context.key }}`. | However, the v3 `ActorConfigSchema` in `src/cleveragents/actor/schema.py` does **not** have a `global_context` field. Since Pydantic's default `extra` behaviour is `"ignore"`, any `global_context` key in an actor YAML file is **silently discarded** when the YAML is loaded via `ActorConfigSchema.from_yaml_file()`. The `YAMLTemplateEngine._create_render_context()` method (in `src/cleveragents/actor/yaml_template_engine.py`) does handle a `context` key, but there is no mechanism to extract `global_context` from the parsed `ActorConfigSchema` and pass it to the template engine. **Expected behaviour:** `ActorConfigSchema` should include a `global_context: dict[str, Any]` field (defaulting to `{}`), and the actor loading pipeline should pass this to the Jinja2 template engine so that `{{ context.key }}` references in actor YAML templates resolve correctly. **Actual behaviour:** `global_context` values in actor YAML files are silently dropped. Any `{{ context.key }}` references in actor YAML templates will resolve to empty strings or cause template errors. **Affected code locations:** - `src/cleveragents/actor/schema.py` — `ActorConfigSchema` class (missing `global_context` field) - `src/cleveragents/actor/yaml_template_engine.py` — `_create_render_context()` method - `docs/specification.md` lines 20178, 20835 ## Subtasks - [ ] Write a failing Behave scenario that loads an actor YAML with a `global_context` block and asserts that `{{ context.key }}` resolves correctly (TDD — commit failing test first) - [ ] Add `global_context: dict[str, Any]` field (default `{}`) to `ActorConfigSchema` in `src/cleveragents/actor/schema.py` - [ ] Update `YAMLTemplateEngine._create_render_context()` in `src/cleveragents/actor/yaml_template_engine.py` to merge `global_context` from the parsed schema into the Jinja2 render context - [ ] Ensure context merge precedence matches the spec: runtime context > plan context > session context > `global_context` - [ ] Verify Pyright passes with strict typing (`nox -e typecheck`) - [ ] Ensure all nox stages pass (`nox`) - [ ] Update or add docstrings for modified classes/methods ## Definition of Done - [ ] Failing Behave scenario committed and merged to `master` before fix is implemented - [ ] `ActorConfigSchema` has a `global_context: dict[str, Any]` field defaulting to `{}` - [ ] `YAMLTemplateEngine._create_render_context()` correctly merges `global_context` into the Jinja2 context with correct precedence - [ ] All Behave unit tests pass (`nox -e unit_tests`) - [ ] All Robot Framework integration tests pass (`nox -e integration_tests`) - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.2.0 milestone 2026-04-03 18:36:54 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have — Spec compliance or quality improvement that should be included in the milestone.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have — Spec compliance or quality improvement that should be included in the milestone. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.2.0 milestone 2026-04-06 22:30:19 +00:00
Author
Owner

This issue has been moved to the backlog as part of an aggressive grooming of the v3.2.0 milestone. It has been deemed non-critical for the minimal viability of the milestone and will be addressed in a future release.

This issue has been moved to the backlog as part of an aggressive grooming of the v3.2.0 milestone. It has been deemed non-critical for the minimal viability of the milestone and will be addressed in a future release.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2477
No description provided.