Repository navigation
Fix/schedule validation errors - #21
Open
timotheegath wants to merge 14 commits into
Open
timotheegath wants to merge 14 commits into
timotheegath wants to merge 14 commits into
Conversation
The first validation check in HospitalEnvironment._process_schedule_request silently returned None for an unknown patient_id, so HospitalTools.execute_action treated the call as executed and the agent lost its turn. Raise the custom ScheduleRequestError instead; execute_action already maps exceptions to status "failed" without action_committed, so the agent is notified and can retry without losing the turn. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Pins the patient_id acceptance criterion of fix/schedule_validation_errors: _process_schedule_request raises ScheduleRequestError, the tool call returns status "failed" without action_committed (so BaseAgent keeps the turn), no state mutates, and a subsequent valid retry commits. Runs without LLM access via a stub protocol and the real HospitalTools.handle_tool_call entry point. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…tient An step_index beyond the patient's pathway length silently returned None, so the tool call looked executed and the agent lost its turn. Also guard negative indices, which previously passed the >= check and silently indexed the pathway from the end. Raises before any state mutation. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Pins the step-index acceptance criterion: beyond-pathway and negative step_index raise ScheduleRequestError, surface as status "failed" without action_committed, mutate no state, and a valid retry afterwards commits. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
If the calling department does not offer the service the patient needs at that step, _process_schedule_request silently returned None and the agent lost its turn. Raise ScheduleRequestError naming both services instead. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Pins the wrong-service acceptance criterion: a department that does not offer the step's service gets ScheduleRequestError surfaced as status "failed" without action_committed, no state mutation, and a retry with the correct department commits. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Scheduling step N without step N-1 already booked silently returned None and the agent lost its turn. Raise ScheduleRequestError requiring steps to be scheduled in order. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Pins the skipped-step acceptance criterion: step N before step N-1 raises ScheduleRequestError, surfaces as status "failed" without action_committed, mutates no state, and scheduling step 0 first then step N commits. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
A start earlier than the patient's arrival time (or the previous step's end plus the cross-hospital transfer penalty) silently returned None and the agent lost its turn. Raise ScheduleRequestError reporting both times. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…ient Pins the minimum-start acceptance criterion for both sources of the bound: the patient's arrival time (step 0) and the previous step's end time (later steps). The rejection surfaces as status "failed" without action_committed, mutates no state, and a valid retry commits. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
… time t A booking overlapping a fully-booked time slot silently returned None and the agent lost its turn. Raise ScheduleRequestError naming the agent, the capacity and the conflicting time. The max-time-horizon guard above it is unchanged. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The validation errors on this branch must not change the deliberate lack-of-resources behavior: the step still books, the tool reports success with action_committed, and a -300/item penalty is recorded per missing resource type. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
A slot reaching t >= max_time_horizon silently returned None and the agent lost its turn. Raise ScheduleRequestError reporting the horizon violation. This was the last silent return in _process_schedule_request. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Pins the horizon acceptance criterion: a slot reaching t >= max_time_horizon - whether by start_time alone or by duration spanning past the horizon - raises ScheduleRequestError, surfaces as status "failed" without action_committed, mutates no state, and a retry inside the horizon commits. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Let agents retry schedule_patient without losing a turn when a call is invalid
Current behaviour
Given a normal hospital environment setup
When an agent tries to schedule a patient and:
Then, the schedule patient tool call fails silently, and the agent loses its turn
Missing resources is intentionally excluded from this list: the step still commits and a −300/item penalty is recorded. It must remain a commit, not an error.
When an agent tries to schedule a patient using a negative patient ID
Then, the schedule patient tool selects the patient by indexing from the end (python-native negative indexing)
Desired behaviour
Failure
Given a normal hospital environment setup
When an agent tries to schedule a patient and:
Then, the agent is notified of the failure and can retry the tool call without losing the turn.
Lack of resources
Given an agent meets all crtieria to schedule a patient, but lacks the resources
When it schedules the patient
Then the tool call does not report a failure to the agent
And a penalty is recorded
Negative indexing
When an agent tries to schedule a patient using a negative patient ID
Then, the agent is notified of the failure and can retry the tool call without losing the turn.
Root cause
HospitalEnvironment._process_schedule_requestreturnsNoneinstead of raising an exception. The callerHospitalTools.execute_actiondoes not consider this a failure due to the lack of exception. The tool call is considered as executed.execute_actionalready maps exceptions to status: "failed" (non-committing).Implementation