Refine agent prompt wording and grounding with identity guidance plus support/resistance masking - #1060
Open
wiliao wants to merge 5 commits into
Open
Refine agent prompt wording and grounding with identity guidance plus support/resistance masking#1060wiliao wants to merge 5 commits into
wiliao wants to merge 5 commits into
Conversation
…ontext - Create identity_resolution.md with explicit symbol reuse rules after `search_symbol` - Update context.py to reference new prompt doc in system prompt guidance
…esistance targets - Expand `_PROSPECTIVE_LEVEL_RE` in `agent/src/agent/grounding.py` - Mask additional level markers such as 支撑/阻力, 压力位/压力线, target/support/resistance, and 均值目标/平均目标 - Prevent technical-level labels like `9.38` from being treated as observed price claims and rejected by the grounding gate - Preserve existing numeric validation behavior for actual observed quotes Tested with `python -m pytest agent/tests/test_agent_grounding.py -q` (79 passed)
- update context.py prompt wording - add exact phrase “Do not re-fetch data you already have.” - normalize “never invent a ticker” wording to match test_agent_output_discipline.py Resolves local prompt discipline failures and prepares change for CI.
- Fixed context.py system prompt text to match output discipline tests - Restored Shadow Account and attribution layer prompt references - Verified full CI Python test step locally (`10144 passed, 16 skipped`)
The grounding gate already rejects a market consumer whose symbol/venue differs from the locked resolver identity (e.g. BLDP.US while only BLDP.TO is locked), but the error left the model to blindly retry the identical unauthorized call. Add an actionable hint for same-issuer, different-venue mismatches: the gate now names the locked identity and the exact search_symbol query to run first. A bare ticker that collides with multiple locked venues gets a "use the full venue-suffixed symbol" hint instead. - agent/src/agent/grounding.py: add _venue_mismatch_hints() and wire it into the identity_mismatch branch of authorize_tool_call - agent/prompts/identity_resolution.md: add "Same issuer, second venue" section (resolve the extra venue with its own search_symbol turn; never bundle two venues into one get_market_data call unless both are locked) Verified: tests/test_agent_grounding.py (79 passed); BLDP.US mismatch now returns the resolver hint and resolving the US venue first unlocks the call.
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.
Summary
agent/src/agent/grounding.pythat treated technical support/resistance target labels as asserted observed price claims._PROSPECTIVE_LEVEL_REso markers like支撑/阻力,压力位/压力线,support/resistance level/line/zone, and均值目标/平均目标are masked as prospective levels.agent/src/agent/context.pyso the agent reuses the locked symbol aftersearch_symbol.agent/src/agent/context.pyto satisfy output discipline tests and restore exact prompt discipline references.Why
9.38as a purported observed price.Trend/bfly-tech-trend-6-months.md.Changes
agent/src/agent/grounding.py._PROSPECTIVE_LEVEL_REto recognize additional Chinese and English trading-plan markers.agent/prompts/identity_resolution.mdwith explicit symbol reuse guidance aftersearch_symbol.agent/src/agent/context.pyto include the new prompt in the system guidance and restore precise output discipline wording..gitignoreto allowagent/prompts/files to stay unignored.agent/prompts/task_routing.mdas supporting task-routing guidance for agent workflows.Note
Test Plan
python -m pytest agent/tests/test_agent_grounding.py -q79 passedRisk & Rollback
agent/src/agent/grounding.pyChecklist
agent/src/agent/grounding.py) is explicitly justified in the PR bodyCo-Authored-By:or AI-assistant attribution trailers added