Skip to content

Integrate device profiles with SCPI query for automatic connection setup #33

Description

@key

Background

Device profiles contain connection settings (baudrate, parity, etc.) and known SCPI commands. Currently, the LLM must manually look up a profile, extract settings, and pass them to serial_query — a multi-step process that wastes context and is error-prone.

Current State

  • get_device_profile (handlers.go:479-503) returns profile with Connection struct
  • serial_query (handlers.go:417-477) requires all connection params explicitly
  • Connection struct (devices.go:27-33) has serial-only fields: baudrate, databits, parity, stopbits, timeout_ms
  • No transport field in Connection — assumes serial
  • No link between profile lookup and query execution
  • LLM workflow: get_device_profile("XDM1241") → extract baudrate, parity, etc. → serial_query(port, cmd, baudrate=115200, ...) — 2 tool calls + manual parameter copying

Problem

  • 2 tool calls required where 1 should suffice
  • LLM must parse JSON, extract fields, and re-pass them — error-prone
  • Connection settings in profile are informational only, not actionable
  • No transport type in profile — can't auto-select serial vs TCP
  • Extra tool call wastes LLM context tokens

Proposed Changes

  1. Add optional device parameter to scpi_query (or serial_query):
    • When provided, auto-lookup device profile from registry
    • Apply profile's connection settings as defaults (baudrate, parity, etc.)
    • Explicitly provided params override profile defaults
  2. Add transport field to Connection struct in device profiles:
    • Values: "serial", "tcp", "usbtmc"
    • Default: "serial" for backward compatibility
  3. Add optional address field to Connection for TCP devices (host:port)
  4. Update device profile JSON schema to include transport info
  5. Single-call workflow: scpi_query(device="XDM1241", port="/dev/ttyUSB0", command="*IDN?")
    • Profile provides baudrate, parity, etc. automatically
    • LLM only needs to specify port (physical mapping) and command

Acceptance Criteria

  • scpi_query accepts optional device param for auto profile lookup
  • Profile connection settings used as defaults when device is specified
  • Explicit params override profile defaults
  • Connection struct supports transport field
  • Device profile JSON schema updated with transport info
  • Tests cover: profile-based defaults, explicit override, missing profile fallback
  • Single tool call can query a known device with minimal params

Affected Files

  • internal/devices/devices.go — add Transport field to Connection
  • internal/devices/profiles/*.json — add transport to profiles
  • internal/tools/tools.go — add device param to query tool
  • internal/tools/handlers.go — profile lookup + merge logic
  • internal/tools/handlers_test.go — tests for integrated flow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions