Skip to content

Commit

Permalink
Merge branch 'main' into feature/vscode-0325
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire authored Jul 31, 2024
2 parents 24eac16 + faca87e commit 1ac6721
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/inspect_ai/model/_providers/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ async def message_param(message: ChatMessage) -> MessageParam:
content: str | list[TextBlockParam | ImageBlockParam] = (
message.error.message
)
# anthropic requires that content be populated when
# is_error is true (throws bad_request_error when not)
# so make sure this precondition is met
if not content:
content = message.text
if not content:
content = "error"
elif isinstance(message.content, str):
content = [TextBlockParam(type="text", text=message.content)]
else:
Expand Down
6 changes: 4 additions & 2 deletions src/inspect_ai/tool/_tools/_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ async def execute(cmd: str) -> str:
if result.success:
return result.stdout
else:
raise ToolError(result.stderr)
raise ToolError(
result.stderr if result.stderr else "error executing command"
)

return execute

Expand Down Expand Up @@ -62,6 +64,6 @@ async def execute(code: str) -> str:
if result.success:
return result.stdout
else:
raise ToolError(result.stderr)
raise ToolError(result.stderr if result.stderr else "error executing code")

return execute

0 comments on commit 1ac6721

Please sign in to comment.