Skip to content

Conversation

@ollmer
Copy link
Collaborator

@ollmer ollmer commented Aug 13, 2025

Description by Korbit AI

What change is being made?

Implement a task hint retrieval system in the tool use agent, enabling dynamic selection of hints through direct, LLM, or embedding-based methods, alongside integrating new models and embedding resources.

Why are these changes being made?

These changes are made to enhance the tool use agent's capability to provide contextual hints for tasks, leveraging modern AI techniques like language models and embeddings, thereby improving task performance and user support without manual hint selection while updating available model configurations and ensuring semantic richness in task-oriented assistance.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Missing Embedding Cache ▹ view ✅ Fix detected
Error Handling Incomplete Error Logging ▹ view
Documentation Incorrect TaskHint.choose_hints() docstring ▹ view
Functionality Missing Goal Validation in Embedding-based Hint Selection ▹ view ✅ Fix detected
Files scanned
File Path Reviewed
src/agentlab/llm/tracking.py
src/agentlab/agents/tool_use_agent/tool_use_agent.py
src/agentlab/analyze/agent_xray.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +378 to +391
try:
hint_topic_idx = json.loads(response.think)
if hint_topic_idx < 0 or hint_topic_idx >= len(hint_topics):
logger.error(f"Wrong LLM hint id response: {response.think}, no hints")
return []
hint_topic = hint_topics[hint_topic_idx]
hint_indices = topic_to_hints[hint_topic]
df = self.hint_db.iloc[hint_indices].copy()
df = df.drop_duplicates(subset=["hint"], keep="first") # leave only unique hints
hints = df["hint"].tolist()
logger.debug(f"LLM hint topic {hint_topic_idx}, chosen hints: {df['hint'].tolist()}")
except json.JSONDecodeError:
logger.error(f"Failed to parse LLM hint id response: {response.think}, no hints")
hints = []
Copy link

Choose a reason for hiding this comment

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

Incomplete Error Logging category Error Handling

Tell me more
What is the issue?

The error handling in choose_hints_llm() loses potentially useful error context by only logging the error message without including the original exception details.

Why this matters

Without the original exception details in the logs, debugging production issues will be more difficult as developers won't have access to the full stack trace and error context.

Suggested change ∙ Feature Preview

Include the exception details in the error logging using exc_info=True:

try:
    hint_topic_idx = json.loads(response.think)
    if hint_topic_idx < 0 or hint_topic_idx >= len(hint_topics):
        logger.error(f"Wrong LLM hint id response: {response.think}, no hints")
        return []
    hint_topic = hint_topics[hint_topic_idx]
    hint_indices = topic_to_hints[hint_topic]
    df = self.hint_db.iloc[hint_indices].copy()
    df = df.drop_duplicates(subset=["hint"], keep="first")  # leave only unique hints
    hints = df["hint"].tolist()
    logger.debug(f"LLM hint topic {hint_topic_idx}, chosen hints: {df['hint'].tolist()}")
except json.JSONDecodeError as e:
    logger.error(f"Failed to parse LLM hint id response: {response.think}, no hints", exc_info=True)
    hints = []
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines +358 to +359
def choose_hints(self, llm, task_name: str, goal: str) -> list[str]:
"""Choose hints based on the task name."""
Copy link

Choose a reason for hiding this comment

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

Incorrect TaskHint.choose_hints() docstring category Documentation

Tell me more
What is the issue?

The docstring is inaccurate as the method chooses hints based on task_name OR goal depending on hint_retrieval_mode, not just task_name.

Why this matters

Misleading docstring could cause confusion about the method's behavior when using different hint retrieval modes.

Suggested change ∙ Feature Preview
def choose_hints(self, llm, task_name: str, goal: str) -> list[str]:
    """Choose hints based on hint_retrieval_mode using task name or goal text."""
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Comment on lines 327 to 334
def encode_hints(self):
self.uniq_hints = self.hint_db.drop_duplicates(subset=["hint"], keep="first")
logger.info(
f"Encoding {len(self.uniq_hints)} unique hints using {self.embedder_model} model."
)
self.hint_embeddings = self.emb_model.encode(
self.uniq_hints["hint"].tolist(), prompt="task hint"
)

This comment was marked as resolved.

Comment on lines 394 to 397
def choose_hints_emb(self, goal: str) -> list[str]:
"""Choose hints using embeddings to filter the hints."""
goal_embeddings = self.emb_model.encode([goal], prompt="task description")
similarities = self.emb_model.similarity(goal_embeddings, self.hint_embeddings)

This comment was marked as resolved.

Copy link
Collaborator

@amanjaiswal73892 amanjaiswal73892 left a comment

Choose a reason for hiding this comment

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

Everything looks good to me.

@amanjaiswal73892 amanjaiswal73892 merged commit b80d731 into main Aug 25, 2025
6 checks passed
@amanjaiswal73892 amanjaiswal73892 deleted the hints_retrieve branch August 25, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants