Skip to content

Commit dfbf858

Browse files
committed
Change ToolResult.content to str
1 parent 9e45daf commit dfbf858

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

splunklib/ai/engines/langchain.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,10 +1354,7 @@ async def _tool_call(
13541354
"ToolException from LangChain should not be raised in tool.func"
13551355
)
13561356

1357-
# TODO: Should we change the splunklib.ai.tools.ToolResult.content to a str, instead of list[str]?
1358-
text_content = "\n".join(result.content)
1359-
1360-
artifact = ToolResult(text_content, result.structured_content)
1357+
artifact = ToolResult(result.content, result.structured_content)
13611358

13621359
if result.structured_content:
13631360
# For both local tools and remote tools (Splunk MCP Server App), the primary
@@ -1371,7 +1368,7 @@ async def _tool_call(
13711368
# this assumption may need to be revisited. For now, this approach is fine.
13721369
# Worst-case scenario is the same information is provided to the LLM twice.
13731370
return asdict(result), artifact # both content + structured_content
1374-
return text_content, artifact
1371+
return result.content, artifact
13751372

13761373
return StructuredTool(
13771374
name=_normalize_tool_name(tool.name, tool.type),

splunklib/ai/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ToolException(Exception):
4040

4141
@dataclass(frozen=True)
4242
class ToolResult:
43-
content: list[str]
43+
content: str
4444
structured_content: dict[str, Any] | None
4545

4646

@@ -243,7 +243,7 @@ def _convert_tool_result(
243243
text_contents.append(content.text)
244244

245245
return ToolResult(
246-
content=text_contents, structured_content=result.structuredContent
246+
content="\n".join(text_contents), structured_content=result.structuredContent
247247
)
248248

249249

tests/unit/ai/test_tool_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
async def no_op() -> ToolResult:
10-
return ToolResult(content=[], structured_content={})
10+
return ToolResult(content="", structured_content={})
1111

1212

1313
LOCAL_TOOL_1 = Tool(

0 commit comments

Comments
 (0)