Skip to content

Fix set_prompt_pom: build a PromptObjectModel from the section list#40

Open
jakubkarolczyk wants to merge 1 commit into
mainfrom
fix/set_prompt_pom-list-to-pom
Open

Fix set_prompt_pom: build a PromptObjectModel from the section list#40
jakubkarolczyk wants to merge 1 commit into
mainfrom
fix/set_prompt_pom-list-to-pom

Conversation

@jakubkarolczyk

Copy link
Copy Markdown

Problem

set_prompt_pom(pom: List[Dict[str, Any]]) stored the raw list (self.agent.pom = pom), but the prompt renderer (PromptManager._process_prompt_sections) calls self.agent.pom.to_dict(). So the documented List[Dict] input crashed at render time:

AttributeError: 'list' object has no attribute 'to_dict'

Prompts built incrementally with prompt_add_section were unaffected — they mutate the existing PromptObjectModel — which is why the bundled examples never tripped it. set_prompt_pom is the only path that overwrites pom with a list.

Fix

Convert the list to a PromptObjectModel (via from_json) before storing; pass through anything already a POM object. One file (core/agent/prompt/manager.py): two imports + the conversion.

Verified

  • set_prompt_pom([...]) now renders prompt:{pom} (previously crashed).
  • Coexists with contextsprompt:{pom, contexts}.
  • Re-setting with a new list replaces cleanly (no accumulation across calls).

@jakubkarolczyk jakubkarolczyk force-pushed the fix/set_prompt_pom-list-to-pom branch from d5211b9 to f5ea1a4 Compare June 26, 2026 09:05
set_prompt_pom stored the raw list (self.agent.pom = pom), but the prompt renderer
(_process_prompt_sections) calls self.agent.pom.to_dict(), so a documented
List[Dict] input crashed at render time with "'list' object has no attribute
'to_dict'". Convert the list to a PromptObjectModel (via from_json) before storing;
pass through anything already a POM. Prompts built incrementally with
prompt_add_section were unaffected — they mutate the existing model — which is why
the bundled examples never tripped this.

Update test_set_prompt_pom_succeeds_when_use_pom_true: it asserted the buggy
contract (agent.pom IS the raw list); now asserts agent.pom is a PromptObjectModel
whose to_dict() equals the input.
@jakubkarolczyk jakubkarolczyk force-pushed the fix/set_prompt_pom-list-to-pom branch from f5ea1a4 to 2fab50d Compare June 26, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant