python-codex 0.5.2__tar.gz → 0.6.0__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 (121) hide show
  1. {python_codex-0.5.2 → python_codex-0.6.0}/PKG-INFO +117 -27
  2. {python_codex-0.5.2 → python_codex-0.6.0}/README.md +116 -26
  3. python_codex-0.6.0/README_ZH.md +233 -0
  4. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/__init__.py +18 -8
  5. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/agent.py +89 -74
  6. python_codex-0.6.0/pycodex/bootstrap.py +162 -0
  7. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/cli.py +19 -14
  8. python_codex-0.6.0/pycodex/config.py +36 -0
  9. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/context.py +369 -51
  10. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/events.py +13 -186
  11. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/model.py +181 -88
  12. python_codex-0.6.0/pycodex/multi_agents.py +401 -0
  13. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/portable/__init__.py +8 -6
  14. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/portable/client.py +24 -39
  15. python_codex-0.6.0/pycodex/portable/protocol.py +28 -0
  16. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/portable/server.py +3 -3
  17. python_codex-0.6.0/pycodex/prompts/developer_messages.json +13 -0
  18. python_codex-0.6.0/pycodex/prompts/goals/budget_limit.md +19 -0
  19. python_codex-0.6.0/pycodex/prompts/goals/continuation.md +56 -0
  20. python_codex-0.6.0/pycodex/prompts/models.json +1819 -0
  21. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/protocol.py +78 -15
  22. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/runtime.py +370 -226
  23. python_codex-0.6.0/pycodex/tools/__init__.py +154 -0
  24. python_codex-0.6.0/pycodex/tools/agent_tool_schemas.py +30 -0
  25. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/apply_patch_tool.py +17 -34
  26. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/base_tool.py +63 -35
  27. python_codex-0.5.2/pycodex/tools/clock_tool.py → python_codex-0.6.0/pycodex/tools/clock_manager.py +44 -105
  28. python_codex-0.6.0/pycodex/tools/clock_tool.py +64 -0
  29. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/code_mode_manager.py +165 -246
  30. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/exec_command_tool.py +0 -18
  31. python_codex-0.6.0/pycodex/tools/exec_runtime.py +381 -0
  32. python_codex-0.6.0/pycodex/tools/exec_tool.py +109 -0
  33. python_codex-0.6.0/pycodex/tools/followup_task_tool.py +44 -0
  34. python_codex-0.6.0/pycodex/tools/goal_manager.py +205 -0
  35. python_codex-0.6.0/pycodex/tools/goal_tool.py +126 -0
  36. python_codex-0.6.0/pycodex/tools/interrupt_agent_tool.py +48 -0
  37. python_codex-0.6.0/pycodex/tools/list_agents_tool.py +66 -0
  38. python_codex-0.6.0/pycodex/tools/python_tool_schema.py +141 -0
  39. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/request_permissions_tool.py +1 -0
  40. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/request_user_input_tool.py +3 -23
  41. python_codex-0.6.0/pycodex/tools/runtime_services.py +222 -0
  42. python_codex-0.6.0/pycodex/tools/send_message_tool.py +42 -0
  43. python_codex-0.6.0/pycodex/tools/spawn_agent_tool.py +83 -0
  44. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/unified_exec_manager.py +26 -35
  45. python_codex-0.6.0/pycodex/tools/wait_agent_tool.py +65 -0
  46. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/wait_tool.py +24 -13
  47. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/web_search_tool.py +1 -0
  48. python_codex-0.6.0/pycodex/utils/codex_config.py +105 -0
  49. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/compactor.py +4 -0
  50. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/compat.py +2 -2
  51. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/doctor.py +5 -4
  52. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/event_helpers.py +143 -13
  53. python_codex-0.6.0/pycodex/utils/history.py +33 -0
  54. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/session_persist.py +78 -36
  55. {python_codex-0.5.2 → python_codex-0.6.0}/pyproject.toml +2 -2
  56. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/__init__.py +2 -0
  57. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/app.py +7 -6
  58. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/config.py +0 -11
  59. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/payload_processors.py +4 -4
  60. python_codex-0.6.0/responses_server/request_translation.py +480 -0
  61. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/server.py +31 -24
  62. python_codex-0.6.0/responses_server/stream_events.py +124 -0
  63. python_codex-0.6.0/responses_server/stream_router.py +356 -0
  64. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/tools/custom_adapter.py +29 -29
  65. python_codex-0.6.0/responses_server/transport.py +332 -0
  66. python_codex-0.5.2/README_ZH.md +0 -179
  67. python_codex-0.5.2/pycodex/bootstrap.py +0 -374
  68. python_codex-0.5.2/pycodex/prompts/models.json +0 -890
  69. python_codex-0.5.2/pycodex/tools/__init__.py +0 -61
  70. python_codex-0.5.2/pycodex/tools/agent_tool_schemas.py +0 -68
  71. python_codex-0.5.2/pycodex/tools/close_agent_tool.py +0 -60
  72. python_codex-0.5.2/pycodex/tools/exec_runtime.js +0 -161
  73. python_codex-0.5.2/pycodex/tools/exec_tool.py +0 -62
  74. python_codex-0.5.2/pycodex/tools/resume_agent_tool.py +0 -54
  75. python_codex-0.5.2/pycodex/tools/runtime_services.py +0 -550
  76. python_codex-0.5.2/pycodex/tools/send_input_tool.py +0 -110
  77. python_codex-0.5.2/pycodex/tools/spawn_agent_tool.py +0 -122
  78. python_codex-0.5.2/pycodex/tools/wait_agent_tool.py +0 -85
  79. python_codex-0.5.2/responses_server/stream_router.py +0 -1153
  80. {python_codex-0.5.2 → python_codex-0.6.0}/.gitignore +0 -0
  81. {python_codex-0.5.2 → python_codex-0.6.0}/LICENSE +0 -0
  82. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/__main__.py +0 -0
  83. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/default_base_instructions.md +0 -0
  84. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/approval_policy/never.md +0 -0
  85. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/approval_policy/on_failure.md +0 -0
  86. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/approval_policy/on_request.md +0 -0
  87. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/approval_policy/on_request_rule_request_permission.md +0 -0
  88. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/approval_policy/unless_trusted.md +0 -0
  89. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/sandbox_mode/danger_full_access.md +0 -0
  90. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/sandbox_mode/read_only.md +0 -0
  91. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/prompts/permissions/sandbox_mode/workspace_write.md +0 -0
  92. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/grep_files_tool.py +0 -0
  93. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/list_dir_tool.py +0 -0
  94. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/read_file_tool.py +0 -0
  95. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/shell_command_tool.py +0 -0
  96. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/shell_tool.py +0 -0
  97. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/update_plan_tool.py +0 -0
  98. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/view_image_tool.py +0 -0
  99. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/tools/write_stdin_tool.py +0 -0
  100. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/__init__.py +0 -0
  101. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/LICENSE +0 -0
  102. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/README.md +0 -0
  103. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/__init__.py +0 -0
  104. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/aes.py +0 -0
  105. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/gcm.py +0 -0
  106. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/_aes_gcm/source-sha256.json +0 -0
  107. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/async_bridge.py +0 -0
  108. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/crypto.py +0 -0
  109. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/debug.py +0 -0
  110. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/dotenv.py +0 -0
  111. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/get_env.py +0 -0
  112. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/image_utils.py +0 -0
  113. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/model_metadata.py +0 -0
  114. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/random_ids.py +0 -0
  115. {python_codex-0.5.2 → python_codex-0.6.0}/pycodex/utils/truncation.py +0 -0
  116. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/__main__.py +0 -0
  117. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/messages_api.py +0 -0
  118. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/session_store.py +0 -0
  119. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/tools/__init__.py +0 -0
  120. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/tools/web_search.py +0 -0
  121. {python_codex-0.5.2 → python_codex-0.6.0}/responses_server/trajectory_dump.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-codex
3
- Version: 0.5.2
3
+ Version: 0.6.0
4
4
  Summary: A minimal Python extraction of Codex's main agent loop
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.6.2
@@ -23,10 +23,15 @@ Description-Content-Type: text/markdown
23
23
  [中文](README_ZH.md)
24
24
 
25
25
  pycodex brings the [Codex](https://github.com/openai/codex) agent loop to Python,
26
- with a CLI, reusable Agent API and browser workspace. It aims to follow upstream
27
- behavior; supported features and deliberate differences are documented in
26
+ with a CLI, reusable Agent API and browser workspace. It targets upstream default
27
+ behavior for the selected features, model and protocol; supported features and
28
+ deliberate differences are documented in
28
29
  [Alignment](docs/ALIGNMENT.md).
29
30
 
31
+ Intentional boundaries include no sandbox enforcement or collaboration-mode
32
+ switching, no OpenAI-specific model/effort allowlists for sub-agents, and no
33
+ requirement to mirror every OpenAI model-catalog entry.
34
+
30
35
  | Package | Provides | Python |
31
36
  | --- | --- | --- |
32
37
  | `python-codex` | Agent, runtime, CLI, tools, Responses compatibility server and portable storage | 3.6.2+ |
@@ -35,6 +40,12 @@ behavior; supported features and deliberate differences are documented in
35
40
  The workspace package installs the matching core version. Python imports use
36
41
  `pycodex`; the commands are `pycodex` and `pycodex-ws`.
37
42
 
43
+ The `exec` tool runs Python with top-level `await` in the host process. Each cell
44
+ has its own namespace, output and tracked asyncio tasks; imports and process
45
+ state are shared. Stopping is cooperative, so run blocking work through
46
+ `tools.exec_command`. Direct file access can use the cell's `cwd` Path.
47
+ See [exec lifecycle and limits](docs/RUNTIME.md#python-exec-cells).
48
+
38
49
  ## Install and run
39
50
 
40
51
  Install the core CLI:
@@ -63,14 +74,21 @@ The built-in `openai` provider uses `OPENAI_API_KEY`. Authentication uses API
63
74
  keys; ChatGPT sign-in credentials from `auth.json` or the OS keychain are not
64
75
  loaded.
65
76
 
77
+ `--profile NAME` selects an adjacent `NAME.config.toml` or an embedded
78
+ `[profiles.NAME]` table. Both recursively merge over the base config, including
79
+ provider and feature tables. A top-level `profile = "NAME"` sets the default;
80
+ `--profile` overrides it. Duplicate names across both formats and missing selected
81
+ profiles are errors. Existing embedded profiles can be used without migration.
82
+
66
83
  ```bash
67
84
  pycodex --profile my_profile "Summarize this repository."
68
85
  pycodex --config /path/to/config.toml
69
86
  pycodex doctor
70
87
  ```
71
88
 
72
- Models use the streaming Responses API. For a Chat Completions backend, set
73
- `use_chat_completion = true` in its provider table. Other backend options include:
89
+ Models use the streaming Responses API; OpenAI models use native Responses
90
+ directly. For a vLLM Chat Completions backend, set `use_chat_completion = true`
91
+ in its provider table. Other backend options include:
74
92
 
75
93
  ```bash
76
94
  pycodex --vllm-endpoint http://127.0.0.1:18000
@@ -79,6 +97,16 @@ pycodex --profile my_profile --use-messages
79
97
 
80
98
  See [context and configuration](docs/CONTEXT.md) and the
81
99
  [Responses compatibility server](docs/responses_server/README.md).
100
+ The compatibility server supports namespaced function/custom tools, including
101
+ upstream Codex subagent tools, with namespace restoration on returned calls.
102
+ Text and reasoning streams include item lifecycle events for Codex's live display.
103
+
104
+ For `step-5-preview` on Step's `step_plan/v1` endpoint, enable
105
+ `use_chat_completion = true` in the Step provider or profile: its native Responses
106
+ endpoint does not expose namespaced collaboration tools correctly. The adapter
107
+ presents names such as `collaboration__spawn_agent` as ordinary functions.
108
+ Prompts follow the declared direct-call names and describe Python `exec`
109
+ collaboration only when both `exec` and collaboration tools are visible.
82
110
 
83
111
  ## CLI
84
112
 
@@ -98,7 +126,6 @@ pycodex --json "Reply with exactly OK."
98
126
  | `/title`, `/history` | Manage the title and inspect conversation history |
99
127
  | `/resume` | List saved sessions; pass an index or session UUID to resume |
100
128
  | `/compact` | Summarize history to free context |
101
- | `/fork` | Continue the current history under a new session ID |
102
129
  | `/queue <message>` | Wait for the active turn to finish before submitting |
103
130
 
104
131
  Ordinary input during a turn steers at the next safe sampling boundary.
@@ -110,8 +137,10 @@ These rules also apply to the browser workspace and Feishu.
110
137
  Sessions are saved under `CODEX_HOME/sessions`. Set
111
138
  `model_auto_compact_token_limit` in the configuration to compact automatically.
112
139
 
113
- Ctrl+D or Ctrl+C closes the CLI after accepted work finishes. A second Ctrl+C
114
- during closing exits immediately. Use `pycodex --help` for startup options.
140
+ Ctrl+D or Ctrl+C stops the session and its child agents: pending turns are
141
+ discarded, and active turns stop after issued model/tool operations finish.
142
+ Session close uses the same behavior. A second Ctrl+C during closing exits
143
+ immediately. Use `pycodex --help` for startup options.
115
144
 
116
145
  ## Browser workspace
117
146
 
@@ -132,17 +161,28 @@ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
132
161
  Open `http://127.0.0.1:6007`. The workspace combines conversations with a live
133
162
  HTML Canvas and read-only file/diff viewers. Click file links in replies to open
134
163
  them, and use **Insert into chat** to add selected code to an editable draft.
164
+ Text and image views support files up to 10 MiB each.
165
+ The context ring opens the built-in Agent tree with `n running · m failed` counts
166
+ (including the root), each Agent's turn duration, and error details for failures.
167
+ Click a root or child Agent in the popover to open its live transcript tab.
168
+ Compare local files with `diff:left..right`; either path can be absolute or relative.
169
+ Use `[TODO](TODO.md)` for a local file link; bare filenames stay as text.
135
170
  Local PDF links open in the browser's built-in reader, with **Open in new tab**
136
171
  and **Download** links. PDF files are streamed separately from text snapshots.
137
172
  Keep the server's stdin open: EOF initiates shutdown.
138
- **New session** directly creates a session using the launch `--profile`, or the
139
- base config when unset. The **+** button on its right (**Custom profile**) lets
140
- you choose a named profile from the server's Codex config; **Default** uses the
141
- launch setting. Each session saves its profile name and uses it again on restart; existing sessions
173
+ **New session** uses the launch `--profile`, then the config's default `profile`,
174
+ then the base config. The **+** button on its right (**Custom profile**) lets
175
+ you choose from adjacent `*.config.toml` files and embedded `[profiles.NAME]`
176
+ tables; **Default** uses the same default selection.
177
+ Each session saves its profile name and uses it again on restart; existing sessions
142
178
  keep their configuration. Restart the server after adding or removing profiles.
179
+ The page loads the last selected session directly on reopening. Switching back
180
+ to a visited session immediately restores its rendered messages and scroll
181
+ position, then refreshes its content from the server.
143
182
  While the selected Agent is working, the empty composer cycles through usage
144
- hints about commands, frontend customization, workspace sharing, session collaboration and optional
145
- features about every six seconds, starting at a random hint. Edit the short
183
+ hints about commands, frontend customization, workspace sharing, Agent status,
184
+ live transcripts and optional features, including clock tick dividers, about every
185
+ six seconds, starting at a random hint. Edit the short
146
186
  strings in the `hints` list in `workspace.html`'s `updatePromptPlaceholder` to change the tips.
147
187
  The gear button opens **Customize Agent** and **Share**, with a short description of each.
148
188
  Customize Agent starts an Agent conversation for editing files in
@@ -171,20 +211,69 @@ workspace backend, including on Remote SSH hosts.
171
211
  Use the standard model and tool setup from Python:
172
212
 
173
213
  ```python
174
- from pycodex.bootstrap import build_agent, build_model
175
-
176
- agent = build_agent(build_model())
177
- try:
178
- result = agent.ask("Summarize this repository in one sentence.")
179
- print(result.output_text)
180
- finally:
181
- agent.shutdown()
214
+ import atexit
215
+
216
+ from pycodex import AgentsManager, CodexConfig
217
+ from pycodex.bootstrap import build_model
218
+ from pycodex.utils.async_bridge import run_async
219
+
220
+ async def main():
221
+ config = CodexConfig.from_env()
222
+ bootstrap = build_model(config.provider)
223
+ if bootstrap.owned_server is not None:
224
+ atexit.register(bootstrap.owned_server.stop)
225
+ runtime = AgentsManager(
226
+ bootstrap.client, config.context,
227
+ ).create_root_runtime()
228
+ await runtime.start()
229
+ try:
230
+ receipt = await runtime.submit_input("Summarize this repository in one sentence.")
231
+ print((await receipt.future).output_text)
232
+ finally:
233
+ await runtime.close()
234
+
235
+ run_async(main())
182
236
  ```
183
237
 
184
- For custom integrations, `Agent` accepts a model client, `ToolRegistry` and
185
- `ContextConfig`. `await agent.run_turn([...])` runs an asynchronous turn;
186
- `AgentRuntime` adds input queues, commands and frontend subscriptions.
187
- See [runtime contracts and examples](docs/RUNTIME.md).
238
+ `CodexConfig.from_env(path, profile)` loads the selected TOML and adjacent `.env`
239
+ once for startup. Pass `config.provider` to `build_model` and `config.context` to
240
+ `AgentsManager`; use `dataclasses.replace` for explicit overrides, including `None`.
241
+ API keys are still read from the environment when requests are sent.
242
+ `build_model` returns `ModelBootstrapResult(client, owned_server)`. The caller owns
243
+ any locally started compatibility server; `close()` stops only that server.
244
+ CLI and workspace entry points retain process-exit cleanup for these services.
245
+
246
+ For custom integrations, `Agent` requires a model client, `ToolRegistry`,
247
+ `ContextConfig` and `session_id`. `await agent.run_turn([...])` runs an asynchronous
248
+ turn; `AgentRuntime(agent, agents_manager)` adds input queues, commands and frontend
249
+ subscriptions. `AgentsManager` owns the tree of named tasks and supplies the
250
+ standard construction path.
251
+
252
+ The current prototype uses MultiAgentV2 tools: `spawn_agent`, `send_message`,
253
+ `followup_task`, `wait_agent`, `interrupt_agent` and `list_agents`. Child context
254
+ inheritance uses `fork_turns`; the session `/fork` command has been removed.
255
+ `features.multi_agent_v2.max_concurrent_threads_per_session` sets the total
256
+ capacity, defaulting to 16 including the root. When full, spawn closes the least
257
+ recently used idle leaf with no pending or background work, or reports a capacity
258
+ error. Closed children are removed from the Agent tree and Workspace views;
259
+ their task names can be reused. The Manager retains closing child references
260
+ until their cleanup finishes, even after they leave the live tree.
261
+ Recorded sessions retain the clock period in a small environment snapshot beside
262
+ the rollout. Resuming starts a fresh countdown and restores `idle: sleeping`
263
+ in attached frontends; child Agents remain in memory.
264
+ Runtime reads execution facts through `Agent.execution_snapshot()`; session
265
+ history and live-state snapshots retain their separate frontend formats.
266
+ Tool factories register shared resource managers with the environment, which
267
+ owns their callbacks, restart, background state and cleanup. Tools provide their
268
+ model-callable behavior. Pass `tools_factory(manager, environment, toolset)` to
269
+ `AgentsManager` to construct custom tools for both root and child Agents; see the
270
+ [resource contract](docs/RUNTIME.md#tools).
271
+ Model clients expose explicit recording metadata; Agent supplies each request's
272
+ session identity through `Prompt`, including compaction and resumed sessions.
273
+ Tool summaries and conversation-history projections are pure helpers shared by
274
+ event and session views.
275
+ See [runtime contracts](docs/RUNTIME.md), [context assembly](docs/CONTEXT.md) and
276
+ the [versioned alignment baseline and remaining differences](docs/ALIGNMENT.md).
188
277
 
189
278
  ## Portable configuration
190
279
 
@@ -222,7 +311,8 @@ uv run --dev pytest
222
311
  - [Responses compatibility server](docs/responses_server/README.md)
223
312
  - [Portable configuration contracts](docs/PORTABLE.md)
224
313
 
225
- Release notes and implementation details live in `docs/`.
314
+ See the [0.6.0 release notes](https://github.com/Randomizez/pycodex/blob/v0.6.0/docs/RELEASE_0.6.0.md) for the major changes and
315
+ Python integration migration from 0.5.0. Implementation details live in `docs/`.
226
316
 
227
317
  ## Markdown view modes
228
318
 
@@ -3,10 +3,15 @@
3
3
  [中文](README_ZH.md)
4
4
 
5
5
  pycodex brings the [Codex](https://github.com/openai/codex) agent loop to Python,
6
- with a CLI, reusable Agent API and browser workspace. It aims to follow upstream
7
- behavior; supported features and deliberate differences are documented in
6
+ with a CLI, reusable Agent API and browser workspace. It targets upstream default
7
+ behavior for the selected features, model and protocol; supported features and
8
+ deliberate differences are documented in
8
9
  [Alignment](docs/ALIGNMENT.md).
9
10
 
11
+ Intentional boundaries include no sandbox enforcement or collaboration-mode
12
+ switching, no OpenAI-specific model/effort allowlists for sub-agents, and no
13
+ requirement to mirror every OpenAI model-catalog entry.
14
+
10
15
  | Package | Provides | Python |
11
16
  | --- | --- | --- |
12
17
  | `python-codex` | Agent, runtime, CLI, tools, Responses compatibility server and portable storage | 3.6.2+ |
@@ -15,6 +20,12 @@ behavior; supported features and deliberate differences are documented in
15
20
  The workspace package installs the matching core version. Python imports use
16
21
  `pycodex`; the commands are `pycodex` and `pycodex-ws`.
17
22
 
23
+ The `exec` tool runs Python with top-level `await` in the host process. Each cell
24
+ has its own namespace, output and tracked asyncio tasks; imports and process
25
+ state are shared. Stopping is cooperative, so run blocking work through
26
+ `tools.exec_command`. Direct file access can use the cell's `cwd` Path.
27
+ See [exec lifecycle and limits](docs/RUNTIME.md#python-exec-cells).
28
+
18
29
  ## Install and run
19
30
 
20
31
  Install the core CLI:
@@ -43,14 +54,21 @@ The built-in `openai` provider uses `OPENAI_API_KEY`. Authentication uses API
43
54
  keys; ChatGPT sign-in credentials from `auth.json` or the OS keychain are not
44
55
  loaded.
45
56
 
57
+ `--profile NAME` selects an adjacent `NAME.config.toml` or an embedded
58
+ `[profiles.NAME]` table. Both recursively merge over the base config, including
59
+ provider and feature tables. A top-level `profile = "NAME"` sets the default;
60
+ `--profile` overrides it. Duplicate names across both formats and missing selected
61
+ profiles are errors. Existing embedded profiles can be used without migration.
62
+
46
63
  ```bash
47
64
  pycodex --profile my_profile "Summarize this repository."
48
65
  pycodex --config /path/to/config.toml
49
66
  pycodex doctor
50
67
  ```
51
68
 
52
- Models use the streaming Responses API. For a Chat Completions backend, set
53
- `use_chat_completion = true` in its provider table. Other backend options include:
69
+ Models use the streaming Responses API; OpenAI models use native Responses
70
+ directly. For a vLLM Chat Completions backend, set `use_chat_completion = true`
71
+ in its provider table. Other backend options include:
54
72
 
55
73
  ```bash
56
74
  pycodex --vllm-endpoint http://127.0.0.1:18000
@@ -59,6 +77,16 @@ pycodex --profile my_profile --use-messages
59
77
 
60
78
  See [context and configuration](docs/CONTEXT.md) and the
61
79
  [Responses compatibility server](docs/responses_server/README.md).
80
+ The compatibility server supports namespaced function/custom tools, including
81
+ upstream Codex subagent tools, with namespace restoration on returned calls.
82
+ Text and reasoning streams include item lifecycle events for Codex's live display.
83
+
84
+ For `step-5-preview` on Step's `step_plan/v1` endpoint, enable
85
+ `use_chat_completion = true` in the Step provider or profile: its native Responses
86
+ endpoint does not expose namespaced collaboration tools correctly. The adapter
87
+ presents names such as `collaboration__spawn_agent` as ordinary functions.
88
+ Prompts follow the declared direct-call names and describe Python `exec`
89
+ collaboration only when both `exec` and collaboration tools are visible.
62
90
 
63
91
  ## CLI
64
92
 
@@ -78,7 +106,6 @@ pycodex --json "Reply with exactly OK."
78
106
  | `/title`, `/history` | Manage the title and inspect conversation history |
79
107
  | `/resume` | List saved sessions; pass an index or session UUID to resume |
80
108
  | `/compact` | Summarize history to free context |
81
- | `/fork` | Continue the current history under a new session ID |
82
109
  | `/queue <message>` | Wait for the active turn to finish before submitting |
83
110
 
84
111
  Ordinary input during a turn steers at the next safe sampling boundary.
@@ -90,8 +117,10 @@ These rules also apply to the browser workspace and Feishu.
90
117
  Sessions are saved under `CODEX_HOME/sessions`. Set
91
118
  `model_auto_compact_token_limit` in the configuration to compact automatically.
92
119
 
93
- Ctrl+D or Ctrl+C closes the CLI after accepted work finishes. A second Ctrl+C
94
- during closing exits immediately. Use `pycodex --help` for startup options.
120
+ Ctrl+D or Ctrl+C stops the session and its child agents: pending turns are
121
+ discarded, and active turns stop after issued model/tool operations finish.
122
+ Session close uses the same behavior. A second Ctrl+C during closing exits
123
+ immediately. Use `pycodex --help` for startup options.
95
124
 
96
125
  ## Browser workspace
97
126
 
@@ -112,17 +141,28 @@ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
112
141
  Open `http://127.0.0.1:6007`. The workspace combines conversations with a live
113
142
  HTML Canvas and read-only file/diff viewers. Click file links in replies to open
114
143
  them, and use **Insert into chat** to add selected code to an editable draft.
144
+ Text and image views support files up to 10 MiB each.
145
+ The context ring opens the built-in Agent tree with `n running · m failed` counts
146
+ (including the root), each Agent's turn duration, and error details for failures.
147
+ Click a root or child Agent in the popover to open its live transcript tab.
148
+ Compare local files with `diff:left..right`; either path can be absolute or relative.
149
+ Use `[TODO](TODO.md)` for a local file link; bare filenames stay as text.
115
150
  Local PDF links open in the browser's built-in reader, with **Open in new tab**
116
151
  and **Download** links. PDF files are streamed separately from text snapshots.
117
152
  Keep the server's stdin open: EOF initiates shutdown.
118
- **New session** directly creates a session using the launch `--profile`, or the
119
- base config when unset. The **+** button on its right (**Custom profile**) lets
120
- you choose a named profile from the server's Codex config; **Default** uses the
121
- launch setting. Each session saves its profile name and uses it again on restart; existing sessions
153
+ **New session** uses the launch `--profile`, then the config's default `profile`,
154
+ then the base config. The **+** button on its right (**Custom profile**) lets
155
+ you choose from adjacent `*.config.toml` files and embedded `[profiles.NAME]`
156
+ tables; **Default** uses the same default selection.
157
+ Each session saves its profile name and uses it again on restart; existing sessions
122
158
  keep their configuration. Restart the server after adding or removing profiles.
159
+ The page loads the last selected session directly on reopening. Switching back
160
+ to a visited session immediately restores its rendered messages and scroll
161
+ position, then refreshes its content from the server.
123
162
  While the selected Agent is working, the empty composer cycles through usage
124
- hints about commands, frontend customization, workspace sharing, session collaboration and optional
125
- features about every six seconds, starting at a random hint. Edit the short
163
+ hints about commands, frontend customization, workspace sharing, Agent status,
164
+ live transcripts and optional features, including clock tick dividers, about every
165
+ six seconds, starting at a random hint. Edit the short
126
166
  strings in the `hints` list in `workspace.html`'s `updatePromptPlaceholder` to change the tips.
127
167
  The gear button opens **Customize Agent** and **Share**, with a short description of each.
128
168
  Customize Agent starts an Agent conversation for editing files in
@@ -151,20 +191,69 @@ workspace backend, including on Remote SSH hosts.
151
191
  Use the standard model and tool setup from Python:
152
192
 
153
193
  ```python
154
- from pycodex.bootstrap import build_agent, build_model
155
-
156
- agent = build_agent(build_model())
157
- try:
158
- result = agent.ask("Summarize this repository in one sentence.")
159
- print(result.output_text)
160
- finally:
161
- agent.shutdown()
194
+ import atexit
195
+
196
+ from pycodex import AgentsManager, CodexConfig
197
+ from pycodex.bootstrap import build_model
198
+ from pycodex.utils.async_bridge import run_async
199
+
200
+ async def main():
201
+ config = CodexConfig.from_env()
202
+ bootstrap = build_model(config.provider)
203
+ if bootstrap.owned_server is not None:
204
+ atexit.register(bootstrap.owned_server.stop)
205
+ runtime = AgentsManager(
206
+ bootstrap.client, config.context,
207
+ ).create_root_runtime()
208
+ await runtime.start()
209
+ try:
210
+ receipt = await runtime.submit_input("Summarize this repository in one sentence.")
211
+ print((await receipt.future).output_text)
212
+ finally:
213
+ await runtime.close()
214
+
215
+ run_async(main())
162
216
  ```
163
217
 
164
- For custom integrations, `Agent` accepts a model client, `ToolRegistry` and
165
- `ContextConfig`. `await agent.run_turn([...])` runs an asynchronous turn;
166
- `AgentRuntime` adds input queues, commands and frontend subscriptions.
167
- See [runtime contracts and examples](docs/RUNTIME.md).
218
+ `CodexConfig.from_env(path, profile)` loads the selected TOML and adjacent `.env`
219
+ once for startup. Pass `config.provider` to `build_model` and `config.context` to
220
+ `AgentsManager`; use `dataclasses.replace` for explicit overrides, including `None`.
221
+ API keys are still read from the environment when requests are sent.
222
+ `build_model` returns `ModelBootstrapResult(client, owned_server)`. The caller owns
223
+ any locally started compatibility server; `close()` stops only that server.
224
+ CLI and workspace entry points retain process-exit cleanup for these services.
225
+
226
+ For custom integrations, `Agent` requires a model client, `ToolRegistry`,
227
+ `ContextConfig` and `session_id`. `await agent.run_turn([...])` runs an asynchronous
228
+ turn; `AgentRuntime(agent, agents_manager)` adds input queues, commands and frontend
229
+ subscriptions. `AgentsManager` owns the tree of named tasks and supplies the
230
+ standard construction path.
231
+
232
+ The current prototype uses MultiAgentV2 tools: `spawn_agent`, `send_message`,
233
+ `followup_task`, `wait_agent`, `interrupt_agent` and `list_agents`. Child context
234
+ inheritance uses `fork_turns`; the session `/fork` command has been removed.
235
+ `features.multi_agent_v2.max_concurrent_threads_per_session` sets the total
236
+ capacity, defaulting to 16 including the root. When full, spawn closes the least
237
+ recently used idle leaf with no pending or background work, or reports a capacity
238
+ error. Closed children are removed from the Agent tree and Workspace views;
239
+ their task names can be reused. The Manager retains closing child references
240
+ until their cleanup finishes, even after they leave the live tree.
241
+ Recorded sessions retain the clock period in a small environment snapshot beside
242
+ the rollout. Resuming starts a fresh countdown and restores `idle: sleeping`
243
+ in attached frontends; child Agents remain in memory.
244
+ Runtime reads execution facts through `Agent.execution_snapshot()`; session
245
+ history and live-state snapshots retain their separate frontend formats.
246
+ Tool factories register shared resource managers with the environment, which
247
+ owns their callbacks, restart, background state and cleanup. Tools provide their
248
+ model-callable behavior. Pass `tools_factory(manager, environment, toolset)` to
249
+ `AgentsManager` to construct custom tools for both root and child Agents; see the
250
+ [resource contract](docs/RUNTIME.md#tools).
251
+ Model clients expose explicit recording metadata; Agent supplies each request's
252
+ session identity through `Prompt`, including compaction and resumed sessions.
253
+ Tool summaries and conversation-history projections are pure helpers shared by
254
+ event and session views.
255
+ See [runtime contracts](docs/RUNTIME.md), [context assembly](docs/CONTEXT.md) and
256
+ the [versioned alignment baseline and remaining differences](docs/ALIGNMENT.md).
168
257
 
169
258
  ## Portable configuration
170
259
 
@@ -202,7 +291,8 @@ uv run --dev pytest
202
291
  - [Responses compatibility server](docs/responses_server/README.md)
203
292
  - [Portable configuration contracts](docs/PORTABLE.md)
204
293
 
205
- Release notes and implementation details live in `docs/`.
294
+ See the [0.6.0 release notes](https://github.com/Randomizez/pycodex/blob/v0.6.0/docs/RELEASE_0.6.0.md) for the major changes and
295
+ Python integration migration from 0.5.0. Implementation details live in `docs/`.
206
296
 
207
297
  ## Markdown view modes
208
298