Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ def log_to_db(self, db):
{
"tool_id": tool_id,
"response_id": response_id,
}
},
ignore=True,
)
for tool_call in self.tool_calls(): # TODO Should be _or_raise()
db["tool_calls"].insert(
Expand Down
18 changes: 18 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,24 @@ def test_default_tool_llm_time():
}


def test_duplicate_tool_name_does_not_crash(logs_db):
"""Passing the same tool twice (same name) should not cause a sqlite UNIQUE constraint error."""
runner = CliRunner()
result = runner.invoke(
cli.cli,
[
"-m",
"echo",
"-T",
"llm_time",
"-T",
"llm_time",
json.dumps({"tool_calls": [{"name": "llm_time"}]}),
],
)
assert result.exit_code == 0


def test_incorrect_tool_usage():
model = llm.get_model("echo")

Expand Down