Skip to content

Main 436#437

Open
DhavalRepo18 wants to merge 10 commits into
mainfrom
main_436
Open

Main 436#437
DhavalRepo18 wants to merge 10 commits into
mainfrom
main_436

Conversation

@DhavalRepo18

Copy link
Copy Markdown
Collaborator

No description provided.

Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
@DhavalRepo18 DhavalRepo18 requested a review from ShuxinLin July 9, 2026 03:41
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Comment thread src/servers/iot/main.py Outdated
Comment thread src/servers/iot/main.py
Comment thread src/servers/iot/main.py
Comment thread src/servers/iot/main.py Outdated
Comment thread src/servers/iot/main.py Outdated
Comment thread src/servers/iot/main.py Outdated
Comment thread src/servers/iot/main.py Outdated
Comment thread src/servers/iot/main.py
@ShuxinLin

Copy link
Copy Markdown
Collaborator

I only went thru the input/output type and docstring of each mcp tools, not implementation. My opinion is we should enhance the signature of mcp tools so that they are more well-defined and easy to understand by agents first.

Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
@DhavalRepo18

Copy link
Copy Markdown
Collaborator Author

@ShuxinLin We adjusted all of your feedback

image

Comment thread src/servers/iot/main.py
if sensor:
values = {sensor: doc.get(sensor)}
else:
values = {k: v for k, v in doc.items() if k not in RESERVED_FIELDS}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When sensor is omitted this returns only the fields present in the newest single document, not all measured sensors. With sparse telemetry it silently omits channels. Either require sensor, or return the latest value per measured sensor with per-sensor timestamps.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ideally sensor should be given. So please remove the else.

Comment thread src/servers/iot/main.py
"n_sensors": len(d.get("sensors", [])),
}
AssetSummary(
asset_id=d["assetnum"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This returns assetnum as asset_id, while asset_ids() returns the telemetry-ready id (iot_asset_id or assetnum). Agents can chain assets() -> history() with CHILLER6 and miss Chiller 6 telemetry. Please return the canonical telemetry asset_id here and expose assetnum/wo_assetnum as aliases.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clarification: if iot_asset_id is present in the real asset registry, then assets() should include/use that value as the canonical telemetry asset_id and expose assetnum separately. If src/couchdb/scenarios_data/shared/iot/asset_profile_sample.json does not match the real registry shape, the sample fixture should be corrected too so local tests exercise the same ID contract.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

asset_id, assetnum --> in real scenarios IoT may represent asset via asset_id and wo has assetnum. but its mappping every real world dataset will have. So not sure what need to be done.

Comment thread src/servers/iot/main.py
return ErrorResult(error="provide at least one sensor name")

matches: List[AssetSensorMatch] = []
for asset_id in _site_asset_ids(site_name):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

_site_asset_ids() returns [] when asset_db is unavailable, so find_assets_by_sensors reports a successful 0 matches instead of a connection error. Please return ErrorResult when the required registry/telemetry DB is missing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adjust if needed.

Comment thread src/servers/iot/main.py
return ErrorResult(error="CouchDB not connected")
limit = max(1, min(limit, PAGE_SIZE))

selector = _time_selector(asset_id, start, end)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Telemetry tools still validate only that the site exists; the query is scoped by asset_id alone. This lets history(site_name="NORTH", asset_id="Chiller 6") return MAIN data. Please either enforce asset-site membership through the registry before querying, or remove site_name from telemetry tools.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This issue, we actually already addressed a long time ago. Not sure why it is coming again.

Comment thread src/servers/iot/main.py
)
for s in sorted(counts)
]
return SensorCoverageResult(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Because max_scan_docs defaults to 5000, these coverage counts may be sampled, but the response has no truncated/has_more/max_scan_docs metadata. Please make partial coverage explicit so agents do not treat sampled counts as complete.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Please add an extra flag indicating the sampled result.

@DhavalRepo18

DhavalRepo18 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

@ShuxinLin, please work with @Miao900 to write the workflow now and make necessary changes in the tool.

@ShuxinLin

Copy link
Copy Markdown
Collaborator

The new/changed IoT tool surface needs tests. The current focused suite fails locally (uv run pytest src/servers/iot/tests/test_tools.py -q: 11 failed, 4 passed), and there are no test cases covering the new tools such as find_assets_by_sensors, stream_extent, sensor_coverage, sensor_stats, or latest_reading. Please update the existing tests for the intentional API changes and add focused unit tests for the new tool behavior/error cases.

Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
Signed-off-by: Dhaval Patel <pateldha@us.ibm.com>
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.

2 participants