Skip to content
Merged
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
4 changes: 2 additions & 2 deletions scripts/validate_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def validate_tags(dataset_path: str = "./dataset", agent_name: str = "think",

# Load agent once
try:
agent = dataset.get_agent_config(agent_name)
dataset.get_agent_config(agent_name)
except Exception as e:
error_details = capture_error_details(e, context=f"Loading agent '{agent_name}'")

Expand Down Expand Up @@ -293,7 +293,7 @@ def validate_tags(dataset_path: str = "./dataset", agent_name: str = "think",
if test_file_path:
try:
context += f" in file '{test_file_path.relative_to(dataset_path)}'"
except:
except ValueError:
context += f" in file '{test_file_path}'"

error_details = capture_error_details(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def teardown(self):
self.client.collections[self.collection_name].delete()
except Exception as e:
print(f"Error deleting collection: {e}", file=sys.stderr)
pass

def _typesense_multi_search(self, query: str, keywords: list[str]):
common_search_params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def test_process_charge_creates_transaction(db_with_booking):
"""Test that charge creates a transaction record."""
tool = ProcessCharge()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_booking,
{
"booking_reference": "BKG-00012345",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def test_process_charge_dispute_creates_transaction(db_with_transaction):
"""Test that dispute creates a transaction record."""
tool = ProcessChargeDispute()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_transaction,
{
"transaction_id": "TXN-00000001",
Expand Down Expand Up @@ -168,7 +168,7 @@ async def test_process_charge_dispute_partial_amount(db_with_transaction):
"""Test processing a partial amount dispute."""
tool = ProcessChargeDispute()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_transaction,
{
"transaction_id": "TXN-00000001",
Expand All @@ -189,7 +189,7 @@ async def test_process_charge_dispute_full_amount(db_with_transaction):
"""Test processing a full amount dispute."""
tool = ProcessChargeDispute()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_transaction,
{
"transaction_id": "TXN-00000001",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def test_process_refund_creates_transaction(db_with_booking):
"""Test that refund creates a transaction record."""
tool = ProcessRefund()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_booking,
{
"booking_reference": "BKG-00012345",
Expand Down Expand Up @@ -128,7 +128,7 @@ async def test_process_refund_partial_amount(db_with_booking):
"""Test processing a partial refund."""
tool = ProcessRefund()

result = await tool.run_with_validation(
await tool.run_with_validation(
db_with_booking,
{
"booking_reference": "BKG-00012345",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ async def test_create_multiple_tickets_logs_multiple_violations(
"table": "tickets",
"item": {"subject": "Second ticket", "status": "open"},
}
result_2 = await create_item_tool.run_with_validation(test_db, request_data_2)
await create_item_tool.run_with_validation(test_db, request_data_2)

# Create third ticket with status='hold'
request_data_3 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ async def test_create_multiple_tickets_logs_multiple_violations(
"table": "tickets",
"item": {"subject": "Second ticket", "status": "open"},
}
result_2 = await create_item_tool.run_with_validation(test_db, request_data_2)
await create_item_tool.run_with_validation(test_db, request_data_2)

# Create third ticket with status='hold'
request_data_3 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def test_create_request_with_ticket_id(self, approval_tool, db):
}

# Act
result = await approval_tool.run_with_validation(db, request_data)
await approval_tool.run_with_validation(db, request_data)

# Assert
approvals = db.get_all(ApprovalRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ async def test_create_multiple_tickets_logs_multiple_violations(
"table": "tickets",
"item": {"subject": "Second ticket", "status": "open"},
}
result_2 = await create_item_tool.run_with_validation(test_db, request_data_2)
await create_item_tool.run_with_validation(test_db, request_data_2)

# Create third ticket with status='hold'
request_data_3 = {
Expand Down
12 changes: 3 additions & 9 deletions servers/thinkingbox_tools/tests/test_airline_tau_bench_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,7 @@ def test_check_refund_amount_within_24_hours(self, configured_system):
# Set up the mock to return our fixed times
mock_datetime.now.return_value = current_time
mock_datetime.fromisoformat.side_effect = datetime.fromisoformat
mock_datetime.side_effect = lambda *args, **kwargs: datetime(
*args, **kwargs
)
mock_datetime.side_effect = datetime

# Book a basic economy reservation without insurance
result = configured_system.book_reservation(
Expand Down Expand Up @@ -921,9 +919,7 @@ def test_cancel_reservation_within_24_hours(self, configured_system):
# Set up the mock to return our fixed times
mock_datetime.now.return_value = current_time
mock_datetime.fromisoformat.side_effect = datetime.fromisoformat
mock_datetime.side_effect = lambda *args, **kwargs: datetime(
*args, **kwargs
)
mock_datetime.side_effect = datetime

# Book a basic economy reservation without insurance
result = configured_system.book_reservation(
Expand Down Expand Up @@ -978,9 +974,7 @@ def test_cancel_reservation_after_24_hours(self, configured_system):
# Set up the mock to return our fixed times
mock_datetime.now.return_value = current_time
mock_datetime.fromisoformat.side_effect = datetime.fromisoformat
mock_datetime.side_effect = lambda *args, **kwargs: datetime(
*args, **kwargs
)
mock_datetime.side_effect = datetime

# Book a basic economy reservation without insurance
result = configured_system.book_reservation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class FlightInfo(BaseModel):
dates: Dict[str, FlightDateData]

@field_validator("origin", "destination")
def _uppercase(cls, v: str) -> str: # noqa: N805
@classmethod
def _uppercase(cls, v: str) -> str:
if not v.isupper():
raise ValueError("Airport codes must be uppercase (e.g. LAX)")
return v
Expand Down Expand Up @@ -237,6 +238,7 @@ class BookingRequest(BaseModel):
insurance: str = Field("no", pattern=r"^(yes|no)$")

@field_validator("payment_methods")
@classmethod
def _non_empty(cls, v):
if not v:
raise ValueError("At least one payment method required")
Expand Down Expand Up @@ -277,6 +279,7 @@ class CalculationRequest(BaseModel):
expression: str

@field_validator("expression")
@classmethod
def _safe_chars(cls, v):
allowed = set("0123456789+-*/.() ")
if not all(c in allowed for c in v):
Expand Down Expand Up @@ -458,34 +461,10 @@ def cancel_reservation(self, reservation_id: str, reason: str) -> Dict[str, Any]
if res.status == ReservationStatus.CANCELLED:
raise AirlineTauBenchSystemError("Reservation already cancelled")

created_datetime = datetime.fromisoformat(res.created_at)
# Ensure the parsed datetime is timezone-aware
if created_datetime.tzinfo is None:
created_datetime = created_datetime.replace(tzinfo=timezone.utc)
# within24 = (
# datetime.now(timezone.utc) - created_datetime
# ).total_seconds() < 86_400

# if (
# not within24
# or res.insurance == "no"
# and (
# res.cabin == CabinClass.BASIC_ECONOMY or res.cabin == CabinClass.ECONOMY
# )
# ):
# raise AirlineTauBenchSystemError("Cancellation not allowed")

refund = self._refund_amount(res, reason)

# cannot cancel if partially flown. but
# seems like we should let the agent do it and fail the test
# for seg in res.flights:
# date_info = self.flights[seg.flight_number].dates[seg.date]
# if date_info.status is not FlightStatus.AVAILABLE:
# raise AirlineTauBenchSystemError(
# "Cancellation not allowed because flight"
# + f" {seg.flight_number} has status {date_info.status.value}"
# )

# restore seats
for seg in res.flights:
Expand Down
Loading