API Reference
This section documents the main classes and helpers exposed by Pygent. The content is generated from the package docstrings.
Agent
Interactive assistant handling messages and tool execution.
Source code in pygent/agent.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
__post_init__()
Initialize defaults after dataclass construction.
Source code in pygent/agent.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
refresh_system_message()
Update the system prompt based on the current tool registry.
Source code in pygent/agent.py
104 105 106 107 108 |
|
run_until_stop(user_msg, max_steps=20, step_timeout=None, max_time=None)
Run steps until stop
is called or limits are reached.
Source code in pygent/agent.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
step(user_msg)
Execute one round of interaction with the model.
Source code in pygent/agent.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
Runtime
Executes commands in a Docker container or locally if Docker is unavailable.
If workspace
or the environment variable PYGENT_WORKSPACE
is set,
the given directory is used as the base workspace and kept across sessions.
Source code in pygent/runtime.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
use_docker
property
Return True
if commands run inside a Docker container.
bash(cmd, timeout=30)
Run a command in the container or locally and return the output.
The executed command is always included in the returned string so the caller can display what was run.
Source code in pygent/runtime.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
export_file(path, dest)
Copy a file or directory from the workspace to a local path.
Source code in pygent/runtime.py
166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
read_file(path, binary=False)
Return the contents of a file relative to the workspace.
Source code in pygent/runtime.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
upload_file(src, dest=None)
Copy a local file or directory into the workspace.
Source code in pygent/runtime.py
152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
TaskManager
Launch agents asynchronously and track their progress.
Source code in pygent/task_manager.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
collect_file(rt, task_id, path, dest=None)
Copy a file or directory from a task workspace into rt
.
Source code in pygent/task_manager.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
start_task(prompt, parent_rt, files=None, parent_depth=0, step_timeout=None, task_timeout=None, persona=None)
Create a new agent and run prompt
asynchronously.
persona
overrides the default rotation used for delegated tasks.
Source code in pygent/task_manager.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
Tools
Tool registry and helper utilities.
clear_tools()
Remove all registered tools globally.
Source code in pygent/tools.py
189 190 191 192 |
|
execute_tool(call, rt)
Dispatch a tool call.
Source code in pygent/tools.py
55 56 57 58 59 60 61 62 |
|
register_tool(name, description, parameters, func)
Register a new callable tool.
Source code in pygent/tools.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
remove_tool(name)
Unregister a specific tool.
Source code in pygent/tools.py
202 203 204 205 206 207 208 209 210 211 |
|
reset_tools()
Restore the default built-in tools.
Source code in pygent/tools.py
195 196 197 198 199 |
|
tool(name, description, parameters)
Decorator for registering a tool.
Source code in pygent/tools.py
45 46 47 48 49 50 51 52 |
|