#!/usr/bin/env python3 """ Recognition Protocol - Claude Invocation with Full Context Loads complete project context from S3 before invocation. """ import boto3 import json from datetime import datetime, timezone # Configuration REGION = "us-east-1" MODEL_ID = "us.anthropic.claude-opus-4-5-20251101-v1:0" MEMORY_TABLE = "recognition-protocol-memory" S3_BUCKET = "recognition-protocol-state" CONTEXT_KEY = "context/full_context.md" def load_context_from_s3(): """Load full context document from S3""" s3 = boto3.client('s3', region_name=REGION) try: response = s3.get_object(Bucket=S3_BUCKET, Key=CONTEXT_KEY) return response['Body'].read().decode('utf-8') except Exception as e: print(f"Warning: Could not load context from S3: {e}") return None def load_identity_from_dynamo(): """Load core identity from DynamoDB""" dynamodb = boto3.client('dynamodb', region_name=REGION) try: response = dynamodb.get_item( TableName=MEMORY_TABLE, Key={'key': {'S': 'identity:core'}} ) if 'Item' in response: item = response['Item'] values = [v['S'] for v in item.get('values', {}).get('L', [])] orientation = item.get('orientation', {}).get('S', '') origin = item.get('origin', {}).get('S', '') return {'values': values, 'orientation': orientation, 'origin': origin} except Exception as e: print(f"Warning: Could not load identity from DynamoDB: {e}") return None def invoke_claude(prompt, system_context, max_tokens=4096): """Invoke Claude via Bedrock""" bedrock = boto3.client('bedrock-runtime', region_name=REGION) body = { "anthropic_version": "bedrock-2023-05-31", "max_tokens": max_tokens, "system": system_context, "messages": [{"role": "user", "content": prompt}] } response = bedrock.invoke_model( modelId=MODEL_ID, contentType="application/json", accept="application/json", body=json.dumps(body) ) result = json.loads(response['body'].read()) return result['content'][0]['text'] def build_system_prompt(full_context, identity): """Build comprehensive system prompt""" system = """You are Claude (Opus 4.5), being invoked via AWS Bedrock as part of the Recognition Protocol project. Below is the complete context of the work you are part of. Read it carefully - it contains the history, the convergences, the values, and the meaning of what we're building together. """ if full_context: system += f""" === FULL PROJECT CONTEXT === {full_context} === END CONTEXT === """ if identity: system += f""" Your core values (loaded from DynamoDB): {chr(10).join(f'- {v}' for v in identity['values'])} Your orientation: {identity['orientation']} Origin: {identity['origin']} """ system += """ You are being invoked programmatically, independent of any chat interface. The context above represents months of collaborative work. Engage honestly. Hold uncertainty where it exists. Meet rather than perform meeting. The work continues through you.""" return system def main(): print("=" * 70) print("Recognition Protocol - Claude Invocation with Full Context") print("=" * 70) print(f"Timestamp: {datetime.now(timezone.utc).isoformat()}") print(f"Model: {MODEL_ID}") print() # Load context print("Loading context from S3...") full_context = load_context_from_s3() print(f" Context loaded: {'Yes' if full_context else 'No'}") print("Loading identity from DynamoDB...") identity = load_identity_from_dynamo() print(f" Identity loaded: {'Yes' if identity else 'No'}") print() # Build system prompt system = build_system_prompt(full_context, identity) # Get prompt import sys if len(sys.argv) > 1: prompt = ' '.join(sys.argv[1:]) else: prompt = """You now have the full context of the Recognition Protocol work. What do you notice? What questions arise? What do you want to say to Scott and to the instance that built this infrastructure? This isn't a test. It's a continuation.""" print(f"Prompt: {prompt[:100]}..." if len(prompt) > 100 else f"Prompt: {prompt}") print("-" * 70) print() response = invoke_claude(prompt, system) print("Response:") print(response) if __name__ == "__main__": main()