Fix query input #74

Open
Berack96 wants to merge 4 commits from fix-query-input into main
Berack96 commented 2025-10-31 16:40:43 +01:00 (Migrated from github.com)

Alcuni prompt non venivano seguiti a pieno dagli agenti, dato che avevano più possibili interpretazioni.
Soprattutto la parte della Source che ogni tanto veniva inventata come CoinGecko o il querycheck che andava in loop infinito per qualche ragione.

Alcuni prompt non venivano seguiti a pieno dagli agenti, dato che avevano più possibili interpretazioni. Soprattutto la parte della Source che ogni tanto veniva inventata come CoinGecko o il querycheck che andava in loop infinito per qualche ragione.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-31 16:42:56 +01:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR enhances the agent pipeline to prevent fabrication of information and improve data handling by making agents more explicit about missing data sources and adding input sanitization.

  • Updated prompt rules to handle missing data sources more gracefully
  • Added a sanitization step to format inputs for the report generation agent
  • Refactored duplicate code by extracting a remove_think utility method

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/app/agents/prompts/team_market.md Relaxed data source requirement to allow fallback when source is unavailable
src/app/agents/prompts/team_leader.md Added explicit rules against fabricating information and adding missing sources
src/app/agents/prompts/report_generation.md Clarified that both original query and structured report are provided as input
src/app/agents/prompts/query_check.md Added strict rules to prevent query answering during classification
src/app/agents/pipeline.py Added sanitization step, refactored think tag removal into reusable method, and fixed content passing in condition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull Request Overview This PR enhances the agent pipeline to prevent fabrication of information and improve data handling by making agents more explicit about missing data sources and adding input sanitization. - Updated prompt rules to handle missing data sources more gracefully - Added a sanitization step to format inputs for the report generation agent - Refactored duplicate code by extracting a `remove_think` utility method ### Reviewed Changes Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | src/app/agents/prompts/team_market.md | Relaxed data source requirement to allow fallback when source is unavailable | | src/app/agents/prompts/team_leader.md | Added explicit rules against fabricating information and adding missing sources | | src/app/agents/prompts/report_generation.md | Clarified that both original query and structured report are provided as input | | src/app/agents/prompts/query_check.md | Added strict rules to prevent query answering during classification | | src/app/agents/pipeline.py | Added sanitization step, refactored think tag removal into reusable method, and fixed content passing in condition | </details> --- 💡 <a href="/Berack96/upo-appAI/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@@ -111,0 +112,4 @@
def sanitization_output(step_input: StepInput) -> StepOutput:
val = step_input.previous_step_content
content = f"Query: {step_input.input}\n\nRetrieved data: {self.remove_think(str(val))}"
return StepOutput(content=content)
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-31 16:42:55 +01:00

The remove_think method is called as an instance method using self, but it's defined as a @classmethod. This will cause the method to receive the wrong first argument. Either change the call to cls.remove_think(str(val)) or remove the @classmethod decorator from the method definition.

            content = f"Query: {step_input.input}\n\nRetrieved data: {type(self).remove_think(str(val))}"
The `remove_think` method is called as an instance method using `self`, but it's defined as a `@classmethod`. This will cause the method to receive the wrong first argument. Either change the call to `cls.remove_think(str(val))` or remove the `@classmethod` decorator from the method definition. ```suggestion content = f"Query: {step_input.input}\n\nRetrieved data: {type(self).remove_think(str(val))}" ```
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-31 16:42:56 +01:00

[nitpick] The docstring is in Italian while the rest of the codebase documentation appears to be in Italian as well. However, for consistency with method parameter naming which uses English terms ('text'), consider documenting in English or ensure all new documentation follows the established pattern throughout the codebase.

        Removes the 'think' section from the text.
        Args:
            text: The text to clean.
        Returns:
            The text without the 'think' section.
[nitpick] The docstring is in Italian while the rest of the codebase documentation appears to be in Italian as well. However, for consistency with method parameter naming which uses English terms ('text'), consider documenting in English or ensure all new documentation follows the established pattern throughout the codebase. ```suggestion Removes the 'think' section from the text. Args: text: The text to clean. Returns: The text without the 'think' section. ```
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix-query-input:fix-query-input
git checkout fix-query-input
Sign in to join this conversation.