Skip to content

add modality-aware Instructions with audio/text variants#4987

Merged
longcw merged 7 commits intomainfrom
longc/modality-aware-instructions
Mar 9, 2026
Merged

add modality-aware Instructions with audio/text variants#4987
longcw merged 7 commits intomainfrom
longc/modality-aware-instructions

Conversation

@longcw
Copy link
Contributor

@longcw longcw commented Mar 3, 2026

No description provided.

@chenghao-mou chenghao-mou requested a review from a team March 3, 2026 14:49
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Member

@chenghao-mou chenghao-mou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested locally with different modalities.

"""
return self._text_variant if self._text_variant is not None else self._audio_variant

def for_modality(self, modality: Literal["audio", "text"]) -> Instructions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we use to_modality, similar to our to_provider_format?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the for_ prefix seems unusual. as_ or to_ are a bit more pythonian.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to as_modality

Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! this feels pretty clean

"""
return self._text_variant if self._text_variant is not None else self._audio_variant

def for_modality(self, modality: Literal["audio", "text"]) -> Instructions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the for_ prefix seems unusual. as_ or to_ are a bit more pythonian.

@longcw longcw merged commit 6b69841 into main Mar 9, 2026
17 checks passed
@longcw longcw deleted the longc/modality-aware-instructions branch March 9, 2026 07:25
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

View 13 additional findings in Devin Review.

Open in Devin Review

Comment on lines +71 to +79
async def book_appointment(self, date: str, time: str) -> None:
"""Book an appointment.

Args:
date: The date of the appointment in the format YYYY-MM-DD
time: The time of the appointment in the format HH:MM
"""
logger.info(f"booking appointment for {date} at {time}")
return f"Appointment booked for {date} at {time}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 book_appointment return type annotation is None but function returns a string

The book_appointment method at line 71 declares -> None but actually returns f"Appointment booked for {date} at {time}" at line 79. Because the function_tool decorator inspects the return type annotation to decide how to handle tool output, a -> None annotation may cause the framework to discard the return value, meaning the LLM never receives the booking confirmation string. This would make the agent unable to confirm to the user that the booking succeeded.

Suggested change
async def book_appointment(self, date: str, time: str) -> None:
"""Book an appointment.
Args:
date: The date of the appointment in the format YYYY-MM-DD
time: The time of the appointment in the format HH:MM
"""
logger.info(f"booking appointment for {date} at {time}")
return f"Appointment booked for {date} at {time}"
@function_tool
async def book_appointment(self, date: str, time: str) -> str:
"""Book an appointment.
Args:
date: The date of the appointment in the format YYYY-MM-DD
time: The time of the appointment in the format HH:MM
"""
logger.info(f"booking appointment for {date} at {time}")
return f"Appointment booked for {date} at {time}"
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants