agentic-python-coder 3.4.1__tar.gz → 3.4.2__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.
Files changed (50) hide show
  1. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/PKG-INFO +1 -1
  2. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/agent.py +51 -5
  3. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/pyproject.toml +1 -1
  4. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/.gitignore +0 -0
  5. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/LICENSE +0 -0
  6. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/README.md +0 -0
  7. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/.gitignore +0 -0
  8. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/prompts/system.md +0 -0
  9. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/prompts/system_todo.md +0 -0
  10. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/__init__.py +0 -0
  11. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/cli.py +0 -0
  12. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/__init__.py +0 -0
  13. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/README.md +0 -0
  14. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/clingo.md +0 -0
  15. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/sample_tasks/bird_reasoning.md +0 -0
  16. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/sample_tasks/diagnosis.md +0 -0
  17. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/sample_tasks/simple_coloring.md +0 -0
  18. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/sample_tasks/stable_marriage.md +0 -0
  19. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/clingo/sample_tasks/sudoku_mini.md +0 -0
  20. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/cpmpy/README.md +0 -0
  21. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/cpmpy/cpmpy.md +0 -0
  22. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/cpmpy/sample_tasks/magic_square.md +0 -0
  23. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/cpmpy/sample_tasks/n_queens.md +0 -0
  24. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/regex/README.md +0 -0
  25. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/regex/regex.md +0 -0
  26. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/regex/sample_tasks/email_extraction.md +0 -0
  27. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/regex/sample_tasks/phone_validation.md +0 -0
  28. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/examples/regex/sample_tasks/url_parsing.md +0 -0
  29. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/kernel.py +0 -0
  30. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/llm.py +0 -0
  31. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/mcp_server.py +0 -0
  32. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/deepseek31.json +0 -0
  33. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gemini25.json +0 -0
  34. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gemini31.json +0 -0
  35. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gemini3flash.json +0 -0
  36. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gemini3pro.json +0 -0
  37. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gpt52.json +0 -0
  38. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gpt56sol.json +0 -0
  39. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/gpt56terra.json +0 -0
  40. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/grok41.json +0 -0
  41. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/opus45.json +0 -0
  42. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/opus48.json +0 -0
  43. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/qwen3.json +0 -0
  44. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/sonnet45.json +0 -0
  45. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/sonnet46.json +0 -0
  46. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/models/sonnet5.json +0 -0
  47. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/project_md.py +0 -0
  48. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/runner.py +0 -0
  49. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/coder/src/agentic_python_coder/tools.py +0 -0
  50. {agentic_python_coder-3.4.1 → agentic_python_coder-3.4.2}/examples/clingo/clingo.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentic-python-coder
3
- Version: 3.4.1
3
+ Version: 3.4.2
4
4
  Summary: A lightweight Python coding agent that writes, executes, and iterates on code through natural language instructions
5
5
  Author: Stefan Szeider
6
6
  License: Apache-2.0
@@ -19,6 +19,55 @@ from agentic_python_coder.tools import (
19
19
  # Default maximum number of steps the agent can take before stopping
20
20
  DEFAULT_STEP_LIMIT = 200
21
21
 
22
+ # Retries for API error responses the OpenAI SDK parses without raising:
23
+ # OpenRouter intermittently returns HTTP 200 whose body is an error object
24
+ # ({"choices": null, "error": {...}}), or a choice with finish_reason "error"
25
+ API_ERROR_MAX_RETRIES = 3
26
+ API_ERROR_BACKOFF_SECONDS = 5
27
+
28
+
29
+ def _response_error(response) -> Optional[str]:
30
+ """Return a description if the response is an error envelope, else None."""
31
+ if not response.choices:
32
+ error = (getattr(response, "model_extra", None) or {}).get("error")
33
+ if error:
34
+ return f"no choices, error: {error}"
35
+ dump = getattr(response, "model_dump_json", None)
36
+ body = dump() if callable(dump) else repr(response)
37
+ return f"no choices, body: {body[:500]}"
38
+ choice = response.choices[0]
39
+ if choice.finish_reason == "error":
40
+ error = (getattr(choice, "model_extra", None) or {}).get("error") or (
41
+ getattr(response, "model_extra", None) or {}
42
+ ).get("error")
43
+ return f"finish_reason 'error', error: {error}"
44
+ return None
45
+
46
+
47
+ def _create_with_retry(llm_config: LLMConfig, request_kwargs: dict, quiet: bool):
48
+ """Call the completions API, retrying error responses.
49
+
50
+ Raises RuntimeError when retries are exhausted, so callers see a failure
51
+ instead of a silent early stop reported as success.
52
+ """
53
+ detail = ""
54
+ for attempt in range(API_ERROR_MAX_RETRIES + 1):
55
+ response = llm_config.client.chat.completions.create(**request_kwargs)
56
+ detail = _response_error(response)
57
+ if detail is None:
58
+ return response
59
+ if not quiet:
60
+ print(
61
+ f"Warning: API returned an error response "
62
+ f"(attempt {attempt + 1}/{API_ERROR_MAX_RETRIES + 1}); {detail}"
63
+ )
64
+ if attempt < API_ERROR_MAX_RETRIES:
65
+ time.sleep(API_ERROR_BACKOFF_SECONDS * (attempt + 1))
66
+ raise RuntimeError(
67
+ f"API returned error responses on {API_ERROR_MAX_RETRIES + 1} attempts; "
68
+ f"last: {detail}"
69
+ )
70
+
22
71
 
23
72
  def load_prompt(prompt_path: Path) -> str:
24
73
  """Load a prompt from file."""
@@ -246,8 +295,8 @@ def run_agent(
246
295
  request_kwargs["tools"] = openai_tools
247
296
  request_kwargs["tool_choice"] = "auto"
248
297
 
249
- # Call API
250
- response = agent.llm_config.client.chat.completions.create(**request_kwargs)
298
+ # Call API (retries transient error responses, raises if they persist)
299
+ response = _create_with_retry(agent.llm_config, request_kwargs, quiet)
251
300
 
252
301
  # Track tokens (some providers return usage objects with None fields)
253
302
  if response.usage:
@@ -261,9 +310,6 @@ def run_agent(
261
310
  response.usage.total_tokens or 0
262
311
  )
263
312
 
264
- if not response.choices:
265
- break
266
-
267
313
  assistant_message = response.choices[0].message
268
314
 
269
315
  # Check for tool calls
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentic-python-coder"
3
- version = "3.4.1"
3
+ version = "3.4.2"
4
4
  description = "A lightweight Python coding agent that writes, executes, and iterates on code through natural language instructions"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13,<3.14"