Skip to content

fix(strategy_v2): accept positional key/value in DiscoveryContext.set_metadata - #209

Merged
brokermr810 merged 1 commit into
OpenByteInc:mainfrom
SAY-5:fix/set-metadata-positional-args
Aug 17, 2026
Merged

fix(strategy_v2): accept positional key/value in DiscoveryContext.set_metadata#209
brokermr810 merged 1 commit into
OpenByteInc:mainfrom
SAY-5:fix/set-metadata-positional-args

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Generated strategies keep calling context.set_metadata("direction_mode", "long_only") positionally, and DiscoveryContext.set_metadata only takes keyword arguments, so POST /api/strategies/generate fails at compile time and the auto-repair round trips into the same TypeError. Accept a (key, value) pair or a mapping in addition to keyword arguments, and spell out the keyword form in the generation prompt so the model is less likely to produce the positional call in the first place.

Fixes #208

Changes

  • strategy_v2/contract.py: set_metadata accepts (key, value) and a mapping as well as keyword arguments
  • ai_generation_contracts.py: show the keyword-argument form of set_metadata in the prompt
  • regression test in test_strategy_v2_contract.py

Test plan

  • Tested locally with docker compose up -d --build
  • Backend logs show no errors
  • Relevant pytest tests pass (tests/test_strategy_v2_contract.py, tests/test_strategy_v2_runtime.py, tests/test_ai_generation_prompt_contracts.py)

API documentation (if routes/schemas changed)

  • Regenerated docs/api/openapi.yaml (cd backend_api_python && python scripts/export_openapi.py)
  • Updated docs/agent/agent-openapi.json if /api/agent/v1 routes changed
  • Breaking API changes called out below (oasdiff will fail CI otherwise)

Screenshots (if UI change)

…_metadata

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@brokermr810
brokermr810 merged commit a6a725e into OpenByteInc:main Aug 17, 2026
9 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.

AI 策略生成总是失败:DiscoveryContext.set_metadata() 拒绝 AI 生成代码的位置参数调用

2 participants