fix: extract agent markdown body as system instruction#31
Closed
samueljklee wants to merge 1 commit intomicrosoft:mainfrom
Closed
fix: extract agent markdown body as system instruction#31samueljklee wants to merge 1 commit intomicrosoft:mainfrom
samueljklee wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When loading agent .md files, the markdown body after frontmatter was being discarded. This body contains the agent's behavioral instructions that should be injected as the system prompt when the agent is spawned via the task tool. Without this fix, agents like smoke-tester that rely on their markdown instructions to guide behavior (e.g., "run this exact recipe path") would receive no system prompt and fall back to generic exploration behavior. Changes: - Parse and preserve markdown body in _load_agent_file_metadata() - Store body as system.instruction in the returned metadata dict
757fe86 to
625165b
Compare
Contributor
Author
|
Fixed in #32 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When loading agent
.mdfiles via_load_agent_file_metadata(), the markdown body after frontmatter was being discarded (assigned to_bodyand ignored). This body contains the agent's behavioral instructions that should be injected as the system prompt when the agent is spawned via the task tool.Fixes: microsoft/amplifier#174
Root Cause
Two issues combined to cause this bug:
_load_agent_file_metadata()discarded the body: The markdown content after frontmatter was parsed but assigned to_body(unused variable) and never stored.load_agent_metadata()was never called: The method existed butBundle.prepare()never invoked it before generating the mount plan.Impact
Agents like
smoke-testerthat rely on their markdown instructions to guide behavior (e.g., "run this exact recipe path") would receive no system prompt and fall back to generic exploration behavior, causing unpredictable results.Solution
_load_agent_file_metadata()to capture the body and store it assystem.instructionself.load_agent_metadata()inBundle.prepare()beforeto_mount_plan()Changes
amplifier_foundation/bundle.py:prepare(): Added call toself.load_agent_metadata()beforeto_mount_plan()_load_agent_file_metadata(): Changed_bodytobody, added logic to store asresult["system"] = {"instruction": body.strip()}Tests
Added 3 tests in
TestAgentMetadataLoading:test_load_agent_metadata_extracts_system_instruction- verifies body becomessystem.instructiontest_load_agent_metadata_preserves_existing_system- verifies explicit inline instructions aren't overwrittentest_load_agent_metadata_empty_body_no_system- verifies empty body doesn't create spurious instructionAll 21 tests pass.
🤖 Generated with Amplifier
Co-Authored-By: Amplifier 240397093+microsoft-amplifier@users.noreply.github.com