Skip to content

fix: system prompt never reaches LLM — agent identity now works - #173

Merged
ULookup merged 1 commit into
mainfrom
infra-fixes-2026-06-20
Jun 22, 2026
Merged

fix: system prompt never reaches LLM — agent identity now works#173
ULookup merged 1 commit into
mainfrom
infra-fixes-2026-06-20

Conversation

@ULookup

@ULookup ULookup commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Critical fix: build_context() was only returning conversation messages, silently dropping the entire system prompt (identity, constraints, world context). The LLM never received "You are Merak" instructions, so DeepSeek defaulted to its training identity "Claude".
  • Identity pipeline: Agent identity now loaded from config/prompts/merak_core.md via the industrial PromptCompositor pipeline, not a truncated hardcoded string.

Root Cause

ContextPipeline::planned_assemble() assembled the full system text and placed it in SerializedPayload.openai_json / anthropic_json, but AgentLoop::build_context() only returned payload.messages (conversation history). The system prompt was computed but never sent to the LLM.

Fix (3 files)

  • context_serializer.hpp — add system_text field to SerializedPayload
  • context_serializer.cpp — expose system text via payload.system_text
  • agent_loop.cpp — prepend system message in build_context(), load identity from PromptCompositor::build_core_sections()

Commits

  • 89a74f4 fix(context): inject system prompt into messages so it reaches the LLM
  • 9bbb87d fix(loop): load agent identity from PromptCompositor pipeline

SerializedPayload.system_text was built by the serializer but never
placed into payload.messages. AgentLoop::build_context() only returned
payload.messages (conversation history), so the system prompt — including
agent identity from merak_core.md — was silently dropped before reaching
the LLM. DeepSeek then defaulted to its training identity ("Claude").

- Add system_text field to SerializedPayload
- Set it in ContextSerializer::serialize()
- Prepend system message in AgentLoop::build_context()
@ULookup
ULookup merged commit d47936e into main Jun 22, 2026
0 of 6 checks passed
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