File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,9 +68,6 @@ Split the monolithic string into a dictionary, each key is a topic:
6868``` python
6969PROMPT_SECTIONS = {
7070 " identity" : " You are a coding agent. Act, don't explain." ,
71- " tools" : " Available tools: bash, read_file, write_file." ,
72- " workspace" : f " Working directory: { WORKDIR } " ,
73- " memory" : " Relevant memories are injected below when available." ,
7471}
7572```
7673
@@ -86,8 +83,12 @@ def assemble_system_prompt(context: dict) -> str:
8683
8784 # Always loaded
8885 sections.append(PROMPT_SECTIONS [" identity" ])
89- sections.append(PROMPT_SECTIONS [" tools" ])
90- sections.append(PROMPT_SECTIONS [" workspace" ])
86+
87+ # Dynamic — tools and workspace from context
88+ tools = " , " .join(context.get(" enabled_tools" , []))
89+ if tools:
90+ sections.append(f " Available tools: { tools} . " )
91+ sections.append(f " Working directory: { context.get(" workspace" , WORKDIR )} " )
9192
9293 # On-demand — based on real state, not keywords
9394 memories = context.get(" memories" , " " )
Original file line number Diff line number Diff line change @@ -68,9 +68,6 @@ s10 は prompt アセンブリ機構に焦点を当てる。s08-s09 の能力を
6868``` python
6969PROMPT_SECTIONS = {
7070 " identity" : " You are a coding agent. Act, don't explain." ,
71- " tools" : " Available tools: bash, read_file, write_file." ,
72- " workspace" : f " Working directory: { WORKDIR } " ,
73- " memory" : " Relevant memories are injected below when available." ,
7471}
7572```
7673
@@ -86,8 +83,12 @@ def assemble_system_prompt(context: dict) -> str:
8683
8784 # 常にロード
8885 sections.append(PROMPT_SECTIONS [" identity" ])
89- sections.append(PROMPT_SECTIONS [" tools" ])
90- sections.append(PROMPT_SECTIONS [" workspace" ])
86+
87+ # context から動的に tools と workspace を取得
88+ tools = " , " .join(context.get(" enabled_tools" , []))
89+ if tools:
90+ sections.append(f " Available tools: { tools} . " )
91+ sections.append(f " Working directory: { context.get(" workspace" , WORKDIR )} " )
9192
9293 # オンデマンド — 実際の状態に基づく、キーワードではない
9394 memories = context.get(" memories" , " " )
Original file line number Diff line number Diff line change @@ -68,9 +68,6 @@ s10 聚焦 prompt 组装机制。以 s08-s09 的能力为背景,但不重复
6868``` python
6969PROMPT_SECTIONS = {
7070 " identity" : " You are a coding agent. Act, don't explain." ,
71- " tools" : " Available tools: bash, read_file, write_file." ,
72- " workspace" : f " Working directory: { WORKDIR } " ,
73- " memory" : " Relevant memories are injected below when available." ,
7471}
7572```
7673
@@ -86,8 +83,12 @@ def assemble_system_prompt(context: dict) -> str:
8683
8784 # 始终加载
8885 sections.append(PROMPT_SECTIONS [" identity" ])
89- sections.append(PROMPT_SECTIONS [" tools" ])
90- sections.append(PROMPT_SECTIONS [" workspace" ])
86+
87+ # 从 context 动态获取 tools 和 workspace
88+ tools = " , " .join(context.get(" enabled_tools" , []))
89+ if tools:
90+ sections.append(f " Available tools: { tools} . " )
91+ sections.append(f " Working directory: { context.get(" workspace" , WORKDIR )} " )
9192
9293 # 按需加载 — 基于真实状态,不是关键词
9394 memories = context.get(" memories" , " " )
Original file line number Diff line number Diff line change 4141
4242PROMPT_SECTIONS = {
4343 "identity" : "You are a coding agent. Act, don't explain." ,
44- "tools" : "Available tools: bash, read_file, write_file." ,
45- "workspace" : f"Working directory: { WORKDIR } " ,
46- "memory" : "Relevant memories are injected below when available." ,
4744}
4845
4946
5047def assemble_system_prompt (context : dict ) -> str :
5148 """Select and join prompt sections based on current context."""
5249 sections = []
5350
54- # Always loaded — identity, tools, workspace
51+ # Always loaded — identity
5552 sections .append (PROMPT_SECTIONS ["identity" ])
56- sections .append (PROMPT_SECTIONS ["tools" ])
57- sections .append (PROMPT_SECTIONS ["workspace" ])
53+
54+ # Dynamic — tools and workspace from context
55+ tools = ", " .join (context .get ("enabled_tools" , []))
56+ if tools :
57+ sections .append (f"Available tools: { tools } ." )
58+ sections .append (f"Working directory: { context .get ("workspace" , WORKDIR )} " )
5859
5960 # Conditional — memory loaded when MEMORY.md exists and has content
6061 memories = context .get ("memories" , "" )
You can’t perform that action at this time.
0 commit comments