Smart HTTP Plugin Citations Integration Fix
Version Implemented: 0.229.001
Issue Description
The Smart HTTP Plugin was not displaying agent citations in chat responses, despite having comprehensive function call tracking implemented. Citations were working correctly for OpenAPI and SQL plugins but were missing for Smart HTTP Plugin calls.
Root Cause Analysis
The citation system in Simplechat works by:
- The
@plugin_function_loggerdecorator automatically logs all plugin function calls to a global plugin invocation logger - The
route_backend_chats.pyfile extracts these logged invocations usingplugin_logger.get_invocations_for_conversation() - These invocations are converted to citation format and stored in the
agent_citationsfield of assistant messages
Problem: The Smart HTTP Plugin was using a custom self.function_calls tracking system instead of the standard @plugin_function_logger decorator used by other plugins.
Solution Implemented
1. Added Plugin Function Logger Import
from semantic_kernel_plugins.plugin_invocation_logger import plugin_function_logger
2. Applied Decorator to Kernel Functions
Applied @plugin_function_logger("SmartHttpPlugin") decorator to both kernel functions:
@plugin_function_logger("SmartHttpPlugin")
@kernel_function(
description="Makes a GET request to a URI with intelligent content size management...",
name="get_web_content"
)
async def get_web_content_async(self, uri: str) -> str:
# Function implementation
@plugin_function_logger("SmartHttpPlugin")
@kernel_function(
description="Makes a POST request to a URI with content size management",
name="post_web_content"
)
async def post_web_content_async(self, uri: str, body: str) -> str:
# Function implementation
3. Maintained Backward Compatibility
- Kept the existing
self.function_callssystem for testing and backward compatibility - The
_track_function_callmethod remains available for internal use - All existing tests continue to work without modification
Technical Details
Integration Pattern
The fix follows the same pattern used by successful plugins like OpenAPI:
- Import
plugin_function_loggerfrom the plugin invocation logger module - Apply
@plugin_function_logger("PluginName")decorator above@kernel_function - The decorator automatically handles all logging to the global system
Automatic Citation Data
The decorator automatically captures:
- Plugin name and function name
- Function parameters (sanitized for security)
- Function results (with size limits)
- Execution timing and success/failure status
- User context and conversation ID for proper isolation
Citation Display Format
Citations will now appear in agent responses with format:
📋 SmartHttpPlugin.get_web_content
🔗 https://example.com/data.json
📊 application/json (150ms, 1250 chars)
📝 {"data": "example response content..."}
Files Modified
Primary Changes
smart_http_plugin.py: Added@plugin_function_loggerdecorator to kernel functions- Version: Updated from 0.228.012 to 0.228.013
Test Files Created
test_smart_http_plugin_decorator_citations.py: Validates decorator integration- Documentation: Updated plugin documentation with integration details
Validation
Decorator Integration Test
Created comprehensive test that validates:
- Plugin initialization with decorators works correctly
- Function calls execute successfully with decorators applied
- No functionality is broken by the decorator addition
- Logging messages confirm decorator is active
Test results:
✅ Successful calls: 2/2
🔧 Plugin logger decorators: Applied to get_web_content and post_web_content
✅ Citation decorator integration working correctly
Application Context Testing
The decorator logs function calls in the application context, which will be picked up by:
plugin_logger.get_invocations_for_conversation()inroute_backend_chats.py- Converted to citation format and included in
agent_citationsfield - Displayed in chat UI alongside agent responses
Benefits
For Users
- Transparency: Clear visibility into what URLs and APIs the agent accessed
- Source Attribution: Direct links to data sources used in responses
- Trust: Verification of information sources and processing methods
- Consistency: Citations now work the same across all plugins
For Developers
- Standard Integration: Uses the established plugin logging framework
- Automatic Handling: No manual citation management required
- Consistent Format: Same citation structure across all plugins
- Debugging: Better insight into plugin function calls and performance
For Agents
- Source Tracking: Automatic tracking of all HTTP requests and data sources
- Performance Insights: Timing information for optimization
- Error Context: Detailed error information for debugging
- Citation Support: Seamless integration with agent citation systems
Testing Recommendations
Functional Testing
- Test Smart HTTP Plugin function calls in agent conversations
- Verify
agent_citationsfield is populated in assistant messages - Confirm citations display correctly in chat UI
- Test with various content types (HTML, JSON, PDF)
Regression Testing
- Ensure existing Smart HTTP Plugin functionality remains intact
- Verify PDF processing still works correctly
- Confirm content size management continues to function
- Test error handling and timeout scenarios
Backward Compatibility
Preserved Functionality
- All existing Smart HTTP Plugin methods work unchanged
- Custom
function_callstracking remains available for testing - PDF processing with Document Intelligence unchanged
- Content size management logic preserved
Migration Notes
- No migration required for existing plugin configurations
- Existing tests continue to work without modification
- Plugin behavior is identical except for citation addition
Future Enhancements
Potential Improvements
- Enhanced Metadata: Add content type detection to citation display
- Performance Metrics: Include detailed timing information in citations
- Error Details: Enhanced error context in failed operation citations
- Citation Filtering: User-controlled citation detail levels
Related Issues
Fixed Issues
- Smart HTTP Plugin citations not displaying in agent responses
- Inconsistent citation support across different plugin types
- Missing source attribution for HTTP-based data retrieval
Technical Debt Resolved
- Manual citation tracking replaced with standard framework
- Plugin logging standardized across all HTTP operations
- Consistent error handling and citation generation