nanocode-cli 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nanocode_cli-0.2.3/nanocode_cli.egg-info → nanocode_cli-0.2.4}/PKG-INFO +1 -1
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode.py +32 -12
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4/nanocode_cli.egg-info}/PKG-INFO +1 -1
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/pyproject.toml +1 -1
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/LICENSE +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/MANIFEST.in +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/README.md +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode_cli.egg-info/SOURCES.txt +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode_cli.egg-info/dependency_links.txt +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode_cli.egg-info/entry_points.txt +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode_cli.egg-info/requires.txt +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/nanocode_cli.egg-info/top_level.txt +0 -0
- {nanocode_cli-0.2.3 → nanocode_cli-0.2.4}/setup.cfg +0 -0
|
@@ -41,7 +41,7 @@ from prompt_toolkit.patch_stdout import patch_stdout
|
|
|
41
41
|
|
|
42
42
|
JsonValue: TypeAlias = Any
|
|
43
43
|
Json: TypeAlias = dict[str, JsonValue]
|
|
44
|
-
__version__ = "0.2.
|
|
44
|
+
__version__ = "0.2.4"
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class Error(Exception): ...
|
|
@@ -1704,7 +1704,7 @@ Core:
|
|
|
1704
1704
|
- Follow the plan, but revise it when facts require it.
|
|
1705
1705
|
|
|
1706
1706
|
Tools:
|
|
1707
|
-
-
|
|
1707
|
+
- MUST use JSON tool_calls. Do not use native <tool_call>Tool(args...) syntax.
|
|
1708
1708
|
- Use multiple tool calls in one turn when they are independent.
|
|
1709
1709
|
- Prefer specific tools first; use Bash only when no provided tool fits.
|
|
1710
1710
|
- Prefer Search before Read when locating code or facts; Read only known small ranges or exact files needed for editing.
|
|
@@ -1729,6 +1729,7 @@ Input:
|
|
|
1729
1729
|
- Current_Context: task-local facts that may expire
|
|
1730
1730
|
- Goal: current objective
|
|
1731
1731
|
- Plan: ordered plan
|
|
1732
|
+
- Agent_Feedback: latest retry/gate warning for you; follow it before continuing
|
|
1732
1733
|
- Latest_Tool_Call_Results: latest raw tool call results
|
|
1733
1734
|
- Latest_User_Input: latest user message
|
|
1734
1735
|
- Tools: available tool specs
|
|
@@ -1834,6 +1835,10 @@ MAIN_AGENT_USER_PROMPT_TEMPLATE = """
|
|
|
1834
1835
|
{verification_state}
|
|
1835
1836
|
-------- Verification_State End -----------
|
|
1836
1837
|
|
|
1838
|
+
----------- Agent_Feedback Begin ------
|
|
1839
|
+
{agent_feedback}
|
|
1840
|
+
-------- Agent_Feedback End -----------
|
|
1841
|
+
|
|
1837
1842
|
----------- Latest_Tool_Call_Results Begin ------
|
|
1838
1843
|
{latest_tool_call_results}
|
|
1839
1844
|
-------- Latest_Tool_Call_Results End -----------
|
|
@@ -1888,7 +1893,7 @@ class PromptBuilder:
|
|
|
1888
1893
|
def system_prompt(self) -> str:
|
|
1889
1894
|
return MAIN_AGENT_SYSTEM_PROMPT.replace("{ __tools__ }", self._format_tools()).strip()
|
|
1890
1895
|
|
|
1891
|
-
def user_prompt(self, latest_tool_call_results: str) -> str:
|
|
1896
|
+
def user_prompt(self, latest_tool_call_results: str, agent_feedback: str) -> str:
|
|
1892
1897
|
current = self.session.current
|
|
1893
1898
|
return MAIN_AGENT_USER_PROMPT_TEMPLATE.format(
|
|
1894
1899
|
environment=self._format_environment(),
|
|
@@ -1898,6 +1903,7 @@ class PromptBuilder:
|
|
|
1898
1903
|
goal=current.goal or "(empty)",
|
|
1899
1904
|
plan=self._format_plan(),
|
|
1900
1905
|
verification_state=current.verification.format(),
|
|
1906
|
+
agent_feedback=agent_feedback or "(empty)",
|
|
1901
1907
|
latest_tool_call_results=latest_tool_call_results or "(empty)",
|
|
1902
1908
|
latest_user_input=current.user_input or "(empty)",
|
|
1903
1909
|
).strip()
|
|
@@ -2669,6 +2675,7 @@ class ConversationCompactor:
|
|
|
2669
2675
|
@final
|
|
2670
2676
|
class Agent:
|
|
2671
2677
|
MAX_CONSECUTIVE_FORMAT_ERRORS: ClassVar[int] = 3
|
|
2678
|
+
MAX_CONSECUTIVE_SUMMARY_GATES: ClassVar[int] = 1
|
|
2672
2679
|
|
|
2673
2680
|
def __init__(self, session: Session):
|
|
2674
2681
|
self.session = session
|
|
@@ -2678,6 +2685,7 @@ class Agent:
|
|
|
2678
2685
|
self.state_updater = AgentStateUpdater(session, self.tool_runner)
|
|
2679
2686
|
self.compactor = ConversationCompactor(session, self.model_client)
|
|
2680
2687
|
self.latest_tool_call_results = ""
|
|
2688
|
+
self.latest_agent_feedback = ""
|
|
2681
2689
|
|
|
2682
2690
|
@property
|
|
2683
2691
|
def latest_tool_call_events(self) -> list[ToolCallEvent]:
|
|
@@ -2687,9 +2695,10 @@ class Agent:
|
|
|
2687
2695
|
return self.prompt_builder.system_prompt()
|
|
2688
2696
|
|
|
2689
2697
|
def build_user_prompt(self, *, consume_latest_tool_results: bool = True) -> str:
|
|
2690
|
-
prompt = self.prompt_builder.user_prompt(self.latest_tool_call_results)
|
|
2698
|
+
prompt = self.prompt_builder.user_prompt(self.latest_tool_call_results, self.latest_agent_feedback)
|
|
2691
2699
|
if consume_latest_tool_results:
|
|
2692
2700
|
self.latest_tool_call_results = ""
|
|
2701
|
+
self.latest_agent_feedback = ""
|
|
2693
2702
|
return prompt
|
|
2694
2703
|
|
|
2695
2704
|
def request(self, system_prompt: str, user_prompt: str, *, activity: str = "main") -> Json:
|
|
@@ -2710,18 +2719,20 @@ class Agent:
|
|
|
2710
2719
|
on_message: MessageCallback | None = None,
|
|
2711
2720
|
) -> Json:
|
|
2712
2721
|
self.latest_tool_call_results = ""
|
|
2722
|
+
self.latest_agent_feedback = ""
|
|
2713
2723
|
self.session.current.user_input = user_input
|
|
2714
2724
|
self.session.current.goal_reached = False
|
|
2715
2725
|
self.maybe_auto_compact()
|
|
2716
2726
|
self.session.append_conversation(UserMessage(content=user_input))
|
|
2717
2727
|
consecutive_format_errors = 0
|
|
2728
|
+
consecutive_summary_gates = 0
|
|
2718
2729
|
|
|
2719
2730
|
for _ in range(self.session.max_agent_steps):
|
|
2720
2731
|
response = self.step()
|
|
2721
2732
|
format_error = _json_str(response.get("_format_error"))
|
|
2722
2733
|
if format_error:
|
|
2723
2734
|
consecutive_format_errors += 1
|
|
2724
|
-
self.
|
|
2735
|
+
self.latest_agent_feedback = format_error
|
|
2725
2736
|
if consecutive_format_errors >= self.MAX_CONSECUTIVE_FORMAT_ERRORS:
|
|
2726
2737
|
self._report_gate(
|
|
2727
2738
|
on_message,
|
|
@@ -2749,14 +2760,23 @@ class Agent:
|
|
|
2749
2760
|
tool_calls = _json_list(response.get("tool_calls"))
|
|
2750
2761
|
summary_gate = self._format_tool_summary_gate(tool_calls)
|
|
2751
2762
|
if summary_gate:
|
|
2752
|
-
|
|
2753
|
-
self.
|
|
2763
|
+
consecutive_summary_gates += 1
|
|
2764
|
+
if consecutive_summary_gates <= self.MAX_CONSECUTIVE_SUMMARY_GATES:
|
|
2765
|
+
self.state_updater.latest_report = ""
|
|
2766
|
+
self.latest_agent_feedback = summary_gate
|
|
2767
|
+
self._report_gate(
|
|
2768
|
+
on_message,
|
|
2769
|
+
"Retrying: model needs to summarize the latest tool results.",
|
|
2770
|
+
self._compact_gate_report(summary_gate),
|
|
2771
|
+
)
|
|
2772
|
+
continue
|
|
2754
2773
|
self._report_gate(
|
|
2755
2774
|
on_message,
|
|
2756
|
-
"
|
|
2757
|
-
|
|
2775
|
+
"Continuing: model did not summarize tool results after one retry.",
|
|
2776
|
+
"Tool_Summary_Gate: allowing continuation after one missing-summary retry.",
|
|
2758
2777
|
)
|
|
2759
|
-
|
|
2778
|
+
else:
|
|
2779
|
+
consecutive_summary_gates = 0
|
|
2760
2780
|
self.apply_response(response)
|
|
2761
2781
|
if on_message is not None and self.state_updater.latest_report:
|
|
2762
2782
|
on_message(self.state_updater.latest_report)
|
|
@@ -2777,7 +2797,7 @@ class Agent:
|
|
|
2777
2797
|
return response
|
|
2778
2798
|
if self.session.current.verification.status == VerificationStatus.REQUIRED:
|
|
2779
2799
|
self.session.current.goal_reached = False
|
|
2780
|
-
self.
|
|
2800
|
+
self.latest_agent_feedback = self._format_verification_gate()
|
|
2781
2801
|
self._report_gate(
|
|
2782
2802
|
on_message,
|
|
2783
2803
|
"Retrying: verification is required before completion.",
|
|
@@ -2785,7 +2805,7 @@ class Agent:
|
|
|
2785
2805
|
)
|
|
2786
2806
|
continue
|
|
2787
2807
|
if not self.session.current.goal_reached:
|
|
2788
|
-
self.
|
|
2808
|
+
self.latest_agent_feedback = self._format_continuation_hint()
|
|
2789
2809
|
self._report_gate(
|
|
2790
2810
|
on_message,
|
|
2791
2811
|
"Continuing: goal is not complete yet.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|