solidworks_mcp.agents.harness¶
solidworks_mcp.agents.harness ¶
PydanticAI harness for validating custom agent prompt responses.
Attributes¶
Classes¶
ErrorRecord ¶
Bases: BaseModel
A normalized error record from an MCP call or planning step.
Attributes:
| Name | Type | Description |
|---|---|---|
error_message |
str
|
The error message value. |
error_type |
str
|
The error type value. |
remediation |
str
|
The remediation value. |
root_cause |
str
|
The root cause value. |
source |
str
|
The source value. |
tool_name |
str
|
The tool name value. |
RecoverableFailure ¶
Bases: BaseModel
Typed failure output used when agent needs user-guided retry.
Attributes:
| Name | Type | Description |
|---|---|---|
explanation |
str
|
The explanation value. |
remediation_steps |
list[str]
|
The remediation steps value. |
retry_focus |
str | None
|
The retry focus value. |
should_retry |
bool
|
The should retry value. |
Functions¶
_extract_data ¶
Build internal extract data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
The result value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result produced by the operation. |
Source code in src/solidworks_mcp/agents/harness.py
_load_agent_prompt ¶
Build internal agent prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_file_name
|
str
|
The agent file name value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The resulting text value. |
Source code in src/solidworks_mcp/agents/harness.py
insert_error ¶
Persist an error with normalized root cause and remediation guidance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
ErrorRecord
|
The record value. |
required |
run_id
|
str | None
|
The run id value. Defaults to None. |
None
|
db_path
|
Path | None
|
The db path value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/agents/history_db.py
insert_run ¶
insert_run(*, run_id: str, agent_name: str, prompt: str, status: str, output_json: str | None, model_name: str | None, db_path: Path | None = None) -> None
Record one prompt run and optionally the validated output payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
The run id value. |
required |
agent_name
|
str
|
The agent name value. |
required |
prompt
|
str
|
The prompt value. |
required |
status
|
str
|
The status value. |
required |
output_json
|
str | None
|
The output json value. |
required |
model_name
|
str | None
|
Embedding model name to use. |
required |
db_path
|
Path | None
|
The db path value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/agents/history_db.py
pretty_json ¶
Return pretty JSON for test output snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
BaseModel
|
The model value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The resulting text value. |
Source code in src/solidworks_mcp/agents/harness.py
run_validated_prompt
async
¶
run_validated_prompt(*, agent_file_name: str, model_name: str, user_prompt: str, result_type: type[TModel], max_retries_on_recoverable: int = 1, db_path: Path | None = None) -> TModel | RecoverableFailure
Run one prompt through PydanticAI and validate the output schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_file_name
|
str
|
The agent file name value. |
required |
model_name
|
str
|
Embedding model name to use. |
required |
user_prompt
|
str
|
The user prompt value. |
required |
result_type
|
type[TModel]
|
The result type value. |
required |
max_retries_on_recoverable
|
int
|
The max retries on recoverable value. Defaults to 1. |
1
|
db_path
|
Path | None
|
The db path value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
TModel | RecoverableFailure
|
TModel | RecoverableFailure: The result produced by the operation. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
Pydantic_ai is not importable. Install dependencies and retry. |
Source code in src/solidworks_mcp/agents/harness.py
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 193 194 195 196 197 198 199 200 201 202 203 204 205 | |