chore: ruff lint

This commit is contained in:
Richard Tang
2026-04-20 19:14:14 -07:00
parent 8da06f4f90
commit c67521a09c
3 changed files with 20 additions and 26 deletions
@@ -101,16 +101,23 @@ Use this tool when you need to ask the user questions during execution. Reach fo
- You want post-task feedback, or to offer saving a skill or updating memory
Usage notes:
- Users will always be able to select "Other" to provide custom text input, so do not include catch-all options like "Other" or "Something else" yourself.
- Each option is a plain string. Do NOT wrap options in `{"label": "..."}` or `{"value": "..."}` objects pass the raw choice text directly, e.g. `"Email"`, not `{"label": "Email"}`.
- If you recommend a specific option, make that the first option in the list and append " (Recommended)" to the end of its text.
- Users will always be able to select "Other" to provide custom text input, \
so do not include catch-all options like "Other" or "Something else" yourself.
- Each option is a plain string. Do NOT wrap options in `{"label": "..."}` or \
`{"value": "..."}` objects pass the raw choice text directly, e.g. `"Email"`, \
not `{"label": "Email"}`.
- If you recommend a specific option, make that the first option in the list \
and append " (Recommended)" to the end of its text.
- Call this tool whenever you need the user's response.
- The prompt field must be plain text only.
- Do not include XML, pseudo-tags, or inline option lists inside prompt.
- Omit options only when the question truly requires a free-form response the user must type out, such as describing an idea or pasting an error message.
- Do not repeat the questions in your normal text response. The widget renders them, so keep any surrounding text to a brief intro only.
- Omit options only when the question truly requires a free-form response the \
user must type out, such as describing an idea or pasting an error message.
- Do not repeat the questions in your normal text response. The widget renders \
them, so keep any surrounding text to a brief intro only.
Example single question with options:
{"questions": [{"id": "next", "prompt": "What would you like to do?", "options": ["Build a new agent (Recommended)", "Modify existing agent", "Run tests"]}]}
{"questions": [{"id": "next", "prompt": "What would you like to do?", \
"options": ["Build a new agent (Recommended)", "Modify existing agent", "Run tests"]}]}
Example batch:
{"questions": [
+1 -2
View File
@@ -771,8 +771,7 @@ class TestCrashRecovery:
"function": {
"name": "ask_user",
"arguments": (
'{"questions":[{"id":"city","prompt":"What city?",'
'"options":["Seattle","Chicago"]}]}'
'{"questions":[{"id":"city","prompt":"What city?","options":["Seattle","Chicago"]}]}'
),
},
}
+6 -18
View File
@@ -128,27 +128,21 @@ def test_array_of_label_objects_unwraps_to_strings() -> None:
def test_array_of_value_objects_unwraps() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": [{"value": "A"}, {"text": "B"}, {"name": "C"}]}
coerce_tool_input(tool, args)
assert args == {"xs": ["A", "B", "C"]}
def test_single_key_object_falls_back_to_sole_value() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": [{"weirdkey": "A"}]}
coerce_tool_input(tool, args)
assert args == {"xs": ["A"]}
def test_unrecognized_object_is_preserved() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": [{"a": "x", "b": "y"}]} # ambiguous — no known key, multi-value
coerce_tool_input(tool, args)
assert args == {"xs": [{"a": "x", "b": "y"}]} # untouched
@@ -158,27 +152,21 @@ def test_unrecognized_object_is_preserved() -> None:
def test_json_string_array_is_parsed() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": '["A","B","C"]'}
coerce_tool_input(tool, args)
assert args == {"xs": ["A", "B", "C"]}
def test_scalar_wraps_into_singleton_array() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": "solo"}
coerce_tool_input(tool, args)
assert args == {"xs": ["solo"]}
def test_invalid_json_string_wraps_as_singleton() -> None:
tool = _tool(
{"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}}
)
tool = _tool({"type": "object", "properties": {"xs": {"type": "array", "items": {"type": "string"}}}})
args = {"xs": "not json [[]"}
coerce_tool_input(tool, args)
assert args == {"xs": ["not json [[]"]}