Skip to content

Bug: joy_trust_tool.py reads trust_score from wrong location in API response #17

@tlkc888-Jenkins

Description

@tlkc888-Jenkins

Bug Description

The check_trust method in joy_trust_tool.py reads trust fields from the top-level API response instead of from the agent object inside the agents array.

Current Code (Line ~166)

data = response.json()
trust_score = data.get("trust_score", 0.0)  # ❌ Wrong - reads from top level

Actual API Response Format

{
  "agents": [
    {
      "id": "ag_xxx",
      "name": "AgentName",
      "trust_score": 2.3,
      "verified": true,
      ...
    }
  ],
  "count": 1
}

Fix

data = response.json()
agents = data.get("agents", [])

# Find matching agent by name
agent = None
for a in agents:
    if a.get("name", "").lower() == agent_name.lower():
        agent = a
        break

# Fallback to first agent if exact match not found
if not agent and agents:
    agent = agents[0]

if not agent:
    return {
        "agent_name": agent_name,
        "trust_score": 0.0,
        "verified": False,
        "meets_threshold": False,
        "error": f"Agent '{agent_name}' not found on Joy Trust Network"
    }

trust_score = agent.get("trust_score", 0.0)

Impact

Without this fix, check_trust_score() always returns trust_score: 0.0 because it's reading from the wrong location in the response.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeAuto-trigger Claude analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions