Files
profitable-expert-advisor/self-coding-agent/agent/__pycache__/loop.cpython-312.pyc
T

78 lines
9.4 KiB
Plaintext
Raw Normal View History

2026-05-27 14:59:00 +02:00
Ë
T×jmãóÒddlmZddlZddlZddlZddlmZmZmZddl m
Z
m Z ddl m
Z
mZmZmZddlmZddlmZmZmZd Zdd
Z dd Zddddd œ dd
Zy)é)Ú annotationsN)ÚAnyÚDictÚListé)Ú load_configÚworkspace_path)Úappend_journalÚload_evolutionÚmaybe_update_evolutionÚ tail_journal)Úchat)Ú ToolExecutorÚ ToolErrorÚparse_model_jsona5
You must reply with ONLY a single raw JSON object (no markdown fences, no commentary) of this form:
{
"reflection": "short reasoning",
"actions": [
{"type": "list_dir", "path": "frontline/units"},
{"type": "read_file", "path": "relative/path/from/repo/root.mq5"},
{"type": "write_file", "path": "self-coding-agent/generated/example.txt", "content": "file contents"},
{"type": "fetch_url", "url": "https://..."},
{"type": "run_backtest", "strategy": "RSIReversalStrategy", "symbol": "XAUUSD", "start": "2023-01-01", "end": "2024-01-01", "timeframe": "H1"},
{"type": "run_python", "script_relative": "backtesting/MT5/test_setup.py", "args": []}
]
}
Rules:
- Paths are relative to the repository root and must stay under allowed prefixes.
- Prefer reading before writing; keep edits minimal and compile-friendly for MQL5.
- Use fetch_url for MQL5 documentation pages when unsure about APIs.
- run_backtest uses the repo's Python MT5 harness (MetaTrader 5 terminal must be installed/running).
- If you only need to think, use an empty actions list.
cóÔt|jd«xsd«j«}|jd«xsg}|dzdjd|D««zdztzS)missionÚÚallowed_path_prefixesz+
Allowed path prefixes (read/write/list):
ú
c3ó&K|] }d|Œ y­w)z- N©)Ú.0Úps ú<D:\profitable-expert-advisor\self-coding-agent\agent\loop.pyú <genexpr>z'build_system_message.<locals>.<genexpr>+sèø€Ò˜”HÑ/ùsú
)ÚstrÚgetÚstripÚjoinÚ
ACTION_SCHEMA)ÚcfgrÚprefixess rÚbuild_system_messager%%srÜ#—''˜Ó+×3€GØw‰wÐ5°2€HàØ

)‰)Ñ/ 
 ñ ô ñ  ðócóðd|d|zdzg}|j«r|jd|z«|j«r|jd|z«|jd«dj|«S)Nz Iteration: z&Previous tool results (JSON):
```json
z
```zRecent journal (tail):
zEvolution memory hint:
zÇPlan the next improvements and output your JSON response. If this is iteration 1 and there is no parse error yet, prefer list_dir/read_file only; avoid run_backtest until you have read relevant code.r)r Úappendr!)Ú iterationÚ last_resultsÚ journal_tailÚevolution_hintÚpartss rÚbuild_user_messager.1s‰ð i
ñ à
ñ ð
€Eð ×ÑÔØ
Ð/°,Ñ×ÑÔØ
Ð/°.Ñ ‡L @ôð
;‰; Ðr&)Úmax_iterationsÚmodelÚ
sleep_secondsÚmt5_backtest_enabledc óÆ
t«}|t|«|jdi«d<t|«}t ||«}|j d«xsi}t
|j dd««}t
|xs|j dd««} |j d«xsi}
|j d «xsi} t||n| j d
d ««} t||n| j d d
««}
t| j dd««}|j d«xsi}t|j dd««}t|«}d }d }tjddi«} |dz
}| r|| kDrtd| «yt|«}|j d«xsg}d}|rtj|ddd¬«}t||«}t||||«}d|dœd|dœg} t!|| ||
¬ «} t#|«}|j d%«xsg}t)|t*«s t-d&«g}d} d'}!t/|d|!«D\}"}#t)|#t0«s|j3dd(d)œ«Œ+ |j5|#«}$|j3|#|$d*œ«|#j d+«d,k(rLt
|$xsij d-«xsd«}%t
|$xsij d.«xsd«}&|%d/z|&z} Œ²tj|j d1«d|d2œd¬«}| j?«r
tA||| «tC|||j d1«|d|!dd3œ«d }td4|d5t
|j d1d««dd6d7t'|d|!««tEjFtId8|
««ŒY#tj$$r+t'|«d!kr|n|dd!d"z}td#|zd$z«wxYw#t6$r+}'|j3|#dt
|'«d)œd*œ«Yd}'~'Œìd}'~'wt8$r:}'|j3|#dt;|'«j<d0|'d)œd*œ«Yd}'~'Œ-d}'~'wwxYw#tJ$rtd9«Yyt8$rÅ}'|dz
}t;|'«j<d0|'d/tMjN«d:d}(t|(«tC||d|(d;œ«tjd<|(id¬«}tQd=td>tQ|d?«z««})||k\rtd@|dA|)dBdC«tEjF|)«Yd}'~'Œ™d}'~'wwxYw)DNÚ mt5_backtestÚenabledÚollamaÚbase_urlzhttp://127.0.0.1:11434r0zllama3.2ÚoptionsÚloopr/rr1gconsecutive_error_limitéÚmemoryÚjournal_max_lineséPÚinfozNo previous tool results yet.Trz!Stopping: reached max_iterations=ÚnotesréýÿÿÿF)Ú ensure_asciiÚsystem)ÚroleÚcontentÚuser)r8i z
...[truncated]...z*Model returned non-JSON; raw (truncated):
z
---Úactionszactions must be a listé zaction must be an object)ÚokÚerror)ÚactionÚresultÚtypeÚ run_backtestÚstdoutÚstderrrz: Ú
reflection)rQÚ parsed_okÚ tool_results)r)rQrGrIz[iter z] ok reflection=é z actions=gzInterrupted by user; exiting.i`ðÿÿ)r)rIrJÚparse_or_run_errorgÀr@éézMany consecutive errors (z ); sleeping z.1fzs before retry.))rÚboolÚ
setdefaultr rrrÚintÚfloatr%ÚjsonÚdumpsÚprintr r
r.rrÚJSONDecodeErrorÚlenÚ
isinstanceÚlistÚ
ValueErrorÚ enumerateÚdictr(ÚexecuterÚ ExceptionrMÚ__name__r r r
ÚtimeÚsleepÚmaxÚKeyboardInterruptÚ tracebackÚ
format_excÚmin)*r/r0r1r2r#ÚwsÚexr6r7Ú
model_namer8Úloop_cfgÚ max_itersÚsleep_sÚ err_limitÚmem_cfgÚ journal_maxrCr)Úconsecutive_errorsÚlast_results_jsonÚevÚev_notesr,r+rFÚmessagesÚrawÚplanÚtailrGÚresultsÚ
backtest_blobÚ max_actionsÚirKÚrrOrPÚerr_textÚbackoffs* rÚrun_loopr‰Is—ô -€CØÐ'Ü8<Ð=QÓ8Rˆ~ *¨9Ñ˜Ó €BÜ c˜2Ó €Bà